]> git.lizzy.rs Git - rust.git/commitdiff
s/AllocType/AllocKind/
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Mon, 3 Dec 2018 15:31:20 +0000 (16:31 +0100)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Mon, 3 Dec 2018 15:31:20 +0000 (16:31 +0100)
src/librustc/ich/impls_ty.rs
src/librustc/mir/interpret/mod.rs
src/librustc/mir/interpret/value.rs
src/librustc/mir/mod.rs
src/librustc_codegen_llvm/common.rs
src/librustc_mir/interpret/memory.rs
src/librustc_mir/interpret/validity.rs
src/librustc_mir/monomorphize/collector.rs

index 00ef3dd414bc9e9a4b75094171b38262dc5cdbe8..56da6b719f4a7287f7b3d749105162a85606cb96 100644 (file)
@@ -338,7 +338,7 @@ impl<Tag> for enum mir::interpret::Scalar<Tag> [ mir::interpret::Scalar ] {
 );
 
 impl_stable_hash_for!(
-    impl<'tcx> for enum mir::interpret::AllocType<'tcx> [ mir::interpret::AllocType ] {
+    impl<'tcx> for enum mir::interpret::AllocKind<'tcx> [ mir::interpret::AllocKind ] {
         Function(instance),
         Static(def_id),
         Memory(mem),
index 8d8128f7a19b906d50f78d0d96f79e6379c45a7b..fbfe0cdae6beda21690583e1f884fb003350d5d2 100644 (file)
@@ -103,20 +103,20 @@ pub fn specialized_encode_alloc_id<
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     alloc_id: AllocId,
 ) -> Result<(), E::Error> {
-    let alloc_type: AllocType<'tcx> =
+    let alloc_type: AllocKind<'tcx> =
         tcx.alloc_map.lock().get(alloc_id).expect("no value for AllocId");
     match alloc_type {
-        AllocType::Memory(alloc) => {
+        AllocKind::Memory(alloc) => {
             trace!("encoding {:?} with {:#?}", alloc_id, alloc);
             AllocDiscriminant::Alloc.encode(encoder)?;
             alloc.encode(encoder)?;
         }
-        AllocType::Function(fn_instance) => {
+        AllocKind::Function(fn_instance) => {
             trace!("encoding {:?} with {:#?}", alloc_id, fn_instance);
             AllocDiscriminant::Fn.encode(encoder)?;
             fn_instance.encode(encoder)?;
         }
-        AllocType::Static(did) => {
+        AllocKind::Static(did) => {
             // referring to statics doesn't need to know about their allocations,
             // just about its DefId
             AllocDiscriminant::Static.encode(encoder)?;
@@ -291,7 +291,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 }
 
 #[derive(Debug, Clone, Eq, PartialEq, Hash, RustcDecodable, RustcEncodable)]
-pub enum AllocType<'tcx> {
+pub enum AllocKind<'tcx> {
     /// The alloc id is used as a function pointer
     Function(Instance<'tcx>),
     /// The alloc id points to a "lazy" static variable that did not get computed (yet).
@@ -303,10 +303,10 @@ pub enum AllocType<'tcx> {
 
 pub struct AllocMap<'tcx> {
     /// Lets you know what an AllocId refers to
-    id_to_type: FxHashMap<AllocId, AllocType<'tcx>>,
+    id_to_type: FxHashMap<AllocId, AllocKind<'tcx>>,
 
     /// Used to ensure that statics only get one associated AllocId
-    type_interner: FxHashMap<AllocType<'tcx>, AllocId>,
+    type_interner: FxHashMap<AllocKind<'tcx>, AllocId>,
 
     /// The AllocId to assign to the next requested id.
     /// Always incremented, never gets smaller.
@@ -339,7 +339,7 @@ pub fn reserve(
         next
     }
 
-    fn intern(&mut self, alloc_type: AllocType<'tcx>) -> AllocId {
+    fn intern(&mut self, alloc_type: AllocKind<'tcx>) -> AllocId {
         if let Some(&alloc_id) = self.type_interner.get(&alloc_type) {
             return alloc_id;
         }
@@ -356,21 +356,21 @@ fn intern(&mut self, alloc_type: AllocType<'tcx>) -> AllocId {
     /// `main as fn() == main as fn()` is false, while `let x = main as fn(); x == x` is true.
     pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> AllocId {
         let id = self.reserve();
-        self.id_to_type.insert(id, AllocType::Function(instance));
+        self.id_to_type.insert(id, AllocKind::Function(instance));
         id
     }
 
     /// Returns `None` in case the `AllocId` is dangling.
     /// This function exists to allow const eval to detect the difference between evaluation-
     /// local dangling pointers and allocations in constants/statics.
-    pub fn get(&self, id: AllocId) -> Option<AllocType<'tcx>> {
+    pub fn get(&self, id: AllocId) -> Option<AllocKind<'tcx>> {
         self.id_to_type.get(&id).cloned()
     }
 
     /// Panics if the `AllocId` does not refer to an `Allocation`
     pub fn unwrap_memory(&self, id: AllocId) -> &'tcx Allocation {
         match self.get(id) {
-            Some(AllocType::Memory(mem)) => mem,
+            Some(AllocKind::Memory(mem)) => mem,
             _ => bug!("expected allocation id {} to point to memory", id),
         }
     }
@@ -378,7 +378,7 @@ pub fn unwrap_memory(&self, id: AllocId) -> &'tcx Allocation {
     /// Generate an `AllocId` for a static or return a cached one in case this function has been
     /// called on the same static before.
     pub fn intern_static(&mut self, static_id: DefId) -> AllocId {
-        self.intern(AllocType::Static(static_id))
+        self.intern(AllocKind::Static(static_id))
     }
 
     /// Intern the `Allocation` and return a new `AllocId`, even if there's already an identical
@@ -395,7 +395,7 @@ pub fn allocate(&mut self, mem: &'tcx Allocation) -> AllocId {
     /// Freeze an `AllocId` created with `reserve` by pointing it at an `Allocation`. Trying to
     /// call this function twice, even with the same `Allocation` will ICE the compiler.
     pub fn set_id_memory(&mut self, id: AllocId, mem: &'tcx Allocation) {
-        if let Some(old) = self.id_to_type.insert(id, AllocType::Memory(mem)) {
+        if let Some(old) = self.id_to_type.insert(id, AllocKind::Memory(mem)) {
             bug!("tried to set allocation id {}, but it was already existing as {:#?}", id, old);
         }
     }
@@ -403,7 +403,7 @@ pub fn set_id_memory(&mut self, id: AllocId, mem: &'tcx Allocation) {
     /// Freeze an `AllocId` created with `reserve` by pointing it at an `Allocation`. May be called
     /// twice for the same `(AllocId, Allocation)` pair.
     pub fn set_id_same_memory(&mut self, id: AllocId, mem: &'tcx Allocation) {
-        self.id_to_type.insert_same(id, AllocType::Memory(mem));
+        self.id_to_type.insert_same(id, AllocKind::Memory(mem));
     }
 }
 
index 4bcba9d54674e3f7f610b59ab4bfaa2c26170b01..16374c92606eee722f4ce0855a01d0902c09df5a 100644 (file)
@@ -18,7 +18,7 @@
 /// Represents the result of a raw const operation, pre-validation.
 #[derive(Copy, Clone, Debug, Eq, PartialEq, RustcEncodable, RustcDecodable, Hash)]
 pub struct RawConst<'tcx> {
-    // the value lives here, at offset 0, and that allocation definitely is a `AllocType::Memory`
+    // the value lives here, at offset 0, and that allocation definitely is a `AllocKind::Memory`
     // (so you can use `AllocMap::unwrap_memory`).
     pub alloc_id: AllocId,
     pub ty: Ty<'tcx>,
index 368f83eb6112731b65ad294b491370ed2066c59c..47058f91525a89e988b79821b3ced0670c974f95 100644 (file)
@@ -2629,7 +2629,7 @@ pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const<'_>) -> fmt::Resu
                 if let Ref(_, &ty::TyS { sty: Str, .. }, _) = ty.sty {
                     return ty::tls::with(|tcx| {
                         let alloc = tcx.alloc_map.lock().get(ptr.alloc_id);
-                        if let Some(interpret::AllocType::Memory(alloc)) = alloc {
+                        if let Some(interpret::AllocKind::Memory(alloc)) = alloc {
                             assert_eq!(len as usize as u128, len);
                             let slice =
                                 &alloc.bytes[(ptr.offset.bytes() as usize)..][..(len as usize)];
index fd13421835c12e522a7556ef1acb3efef2f9d091..0d9c417f5229ba3164f3d83b5b397666b43204c2 100644 (file)
@@ -21,7 +21,7 @@
 use rustc_codegen_ssa::traits::*;
 
 use rustc::ty::layout::{HasDataLayout, LayoutOf, self, TyLayout, Size};
-use rustc::mir::interpret::{Scalar, AllocType, Allocation};
+use rustc::mir::interpret::{Scalar, AllocKind, Allocation};
 use consts::const_alloc_to_llvm;
 use rustc_codegen_ssa::mir::place::PlaceRef;
 
@@ -318,7 +318,7 @@ fn scalar_to_backend(
             Scalar::Ptr(ptr) => {
                 let alloc_type = self.tcx.alloc_map.lock().get(ptr.alloc_id);
                 let base_addr = match alloc_type {
-                    Some(AllocType::Memory(alloc)) => {
+                    Some(AllocKind::Memory(alloc)) => {
                         let init = const_alloc_to_llvm(self, alloc);
                         if alloc.mutability == Mutability::Mutable {
                             self.static_addr_of_mut(init, alloc.align, None)
@@ -326,10 +326,10 @@ fn scalar_to_backend(
                             self.static_addr_of(init, alloc.align, None)
                         }
                     }
-                    Some(AllocType::Function(fn_instance)) => {
+                    Some(AllocKind::Function(fn_instance)) => {
                         self.get_fn(fn_instance)
                     }
-                    Some(AllocType::Static(def_id)) => {
+                    Some(AllocKind::Static(def_id)) => {
                         assert!(self.tcx.is_static(def_id).is_some());
                         self.get_static(def_id)
                     }
index 97d7e1586b811354abed733e7fc43497180e0395..cc96976e74a3055516a947b0cdc9bd605d366738 100644 (file)
@@ -29,7 +29,7 @@
 
 use super::{
     Pointer, AllocId, Allocation, GlobalId, AllocationExtra,
-    EvalResult, Scalar, EvalErrorKind, AllocType, PointerArithmetic,
+    EvalResult, Scalar, EvalErrorKind, AllocKind, PointerArithmetic,
     Machine, AllocMap, MayLeak, ErrorHandled, InboundsCheck,
 };
 
@@ -204,12 +204,12 @@ pub fn deallocate(
             None => {
                 // Deallocating static memory -- always an error
                 return match self.tcx.alloc_map.lock().get(ptr.alloc_id) {
-                    Some(AllocType::Function(..)) => err!(DeallocatedWrongMemoryKind(
+                    Some(AllocKind::Function(..)) => err!(DeallocatedWrongMemoryKind(
                         "function".to_string(),
                         format!("{:?}", kind),
                     )),
-                    Some(AllocType::Static(..)) |
-                    Some(AllocType::Memory(..)) => err!(DeallocatedWrongMemoryKind(
+                    Some(AllocKind::Static(..)) |
+                    Some(AllocKind::Memory(..)) => err!(DeallocatedWrongMemoryKind(
                         "static".to_string(),
                         format!("{:?}", kind),
                     )),
@@ -326,15 +326,15 @@ fn get_static_alloc(
     ) -> EvalResult<'tcx, Cow<'tcx, Allocation<M::PointerTag, M::AllocExtra>>> {
         let alloc = tcx.alloc_map.lock().get(id);
         let def_id = match alloc {
-            Some(AllocType::Memory(mem)) => {
+            Some(AllocKind::Memory(mem)) => {
                 // We got tcx memory. Let the machine figure out whether and how to
                 // turn that into memory with the right pointer tag.
                 return Ok(M::adjust_static_allocation(mem, memory_extra))
             }
-            Some(AllocType::Function(..)) => {
+            Some(AllocKind::Function(..)) => {
                 return err!(DerefFunctionPointer)
             }
-            Some(AllocType::Static(did)) => {
+            Some(AllocKind::Static(did)) => {
                 did
             }
             None =>
@@ -435,8 +435,8 @@ pub fn get_size_and_align(&self, id: AllocId) -> (Size, Align) {
         }
         // Could also be a fn ptr or extern static
         match self.tcx.alloc_map.lock().get(id) {
-            Some(AllocType::Function(..)) => (Size::ZERO, Align::from_bytes(1).unwrap()),
-            Some(AllocType::Static(did)) => {
+            Some(AllocKind::Function(..)) => (Size::ZERO, Align::from_bytes(1).unwrap()),
+            Some(AllocKind::Static(did)) => {
                 // The only way `get` couldn't have worked here is if this is an extern static
                 assert!(self.tcx.is_foreign_item(did));
                 // Use size and align of the type
@@ -459,7 +459,7 @@ pub fn get_fn(&self, ptr: Pointer<M::PointerTag>) -> EvalResult<'tcx, Instance<'
         }
         trace!("reading fn ptr: {}", ptr.alloc_id);
         match self.tcx.alloc_map.lock().get(ptr.alloc_id) {
-            Some(AllocType::Function(instance)) => Ok(instance),
+            Some(AllocKind::Function(instance)) => Ok(instance),
             _ => Err(EvalErrorKind::ExecuteMemory.into()),
         }
     }
@@ -557,16 +557,16 @@ pub fn dump_allocs(&self, mut allocs: Vec<AllocId>) {
                 Err(()) => {
                     // static alloc?
                     match self.tcx.alloc_map.lock().get(id) {
-                        Some(AllocType::Memory(alloc)) => {
+                        Some(AllocKind::Memory(alloc)) => {
                             self.dump_alloc_helper(
                                 &mut allocs_seen, &mut allocs_to_print,
                                 msg, alloc, " (immutable)".to_owned()
                             );
                         }
-                        Some(AllocType::Function(func)) => {
+                        Some(AllocKind::Function(func)) => {
                             trace!("{} {}", msg, func);
                         }
-                        Some(AllocType::Static(did)) => {
+                        Some(AllocKind::Static(did)) => {
                             trace!("{} {:?}", msg, did);
                         }
                         None => {
index d98d05bc01b8504905e74987db362b474da3e87d..bf771789c8dee1ddd5155fb5198ecb138d770a4b 100644 (file)
@@ -17,7 +17,7 @@
 use rustc::ty;
 use rustc_data_structures::fx::FxHashSet;
 use rustc::mir::interpret::{
-    Scalar, AllocType, EvalResult, EvalErrorKind,
+    Scalar, AllocKind, EvalResult, EvalErrorKind,
 };
 
 use super::{
@@ -388,7 +388,7 @@ fn visit_primitive(&mut self, value: OpTy<'tcx, M::PointerTag>) -> EvalResult<'t
                             "integer pointer in non-ZST reference", self.path);
                         // Skip validation entirely for some external statics
                         let alloc_kind = self.ecx.tcx.alloc_map.lock().get(ptr.alloc_id);
-                        if let Some(AllocType::Static(did)) = alloc_kind {
+                        if let Some(AllocKind::Static(did)) = alloc_kind {
                             // `extern static` cannot be validated as they have no body.
                             // FIXME: Statics from other crates are also skipped.
                             // They might be checked at a different type, but for now we
index 7531f62fdab7b7f8f42d8fbb9670986be8503592..ec5c57ee0ba68d435e5796996f4d3c4e5160ac88 100644 (file)
 use rustc::mir::{self, Location, Promoted};
 use rustc::mir::visit::Visitor as MirVisitor;
 use rustc::mir::mono::MonoItem;
-use rustc::mir::interpret::{Scalar, GlobalId, AllocType, ErrorHandled};
+use rustc::mir::interpret::{Scalar, GlobalId, AllocKind, ErrorHandled};
 
 use monomorphize::{self, Instance};
 use rustc::util::nodemap::{FxHashSet, FxHashMap, DefIdMap};
@@ -1163,20 +1163,20 @@ fn collect_miri<'a, 'tcx>(
 ) {
     let alloc_type = tcx.alloc_map.lock().get(alloc_id);
     match alloc_type {
-        Some(AllocType::Static(did)) => {
+        Some(AllocKind::Static(did)) => {
             let instance = Instance::mono(tcx, did);
             if should_monomorphize_locally(tcx, &instance) {
                 trace!("collecting static {:?}", did);
                 output.push(MonoItem::Static(did));
             }
         }
-        Some(AllocType::Memory(alloc)) => {
+        Some(AllocKind::Memory(alloc)) => {
             trace!("collecting {:?} with {:#?}", alloc_id, alloc);
             for &((), inner) in alloc.relocations.values() {
                 collect_miri(tcx, inner, output);
             }
         },
-        Some(AllocType::Function(fn_instance)) => {
+        Some(AllocKind::Function(fn_instance)) => {
             if should_monomorphize_locally(tcx, &fn_instance) {
                 trace!("collecting {:?} with {:#?}", alloc_id, fn_instance);
                 output.push(create_fn_mono_item(fn_instance));