about summary refs log tree commit diff
path: root/src/librustc_mir/interpret
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-12-13 12:36:13 +0000
committerbors <bors@rust-lang.org>2018-12-13 12:36:13 +0000
commit7489ee9c6f92050a12a3a3097df0a7d3737d82ec (patch)
treeed427440d561cfc0f7bcd420e7386e86d9f1893f /src/librustc_mir/interpret
parent9fe5cb5342244a716055fa0162e795deabd4985c (diff)
parent7181aa176393d601f43704d886e8e7afa4b14e45 (diff)
downloadrust-7489ee9c6f92050a12a3a3097df0a7d3737d82ec.tar.gz
rust-7489ee9c6f92050a12a3a3097df0a7d3737d82ec.zip
Auto merge of #56461 - oli-obk:alloc_ids, r=RalfJung
Some cleanups around `AllocId` management

r? @eddyb
cc @RalfJung
Diffstat (limited to 'src/librustc_mir/interpret')
-rw-r--r--src/librustc_mir/interpret/memory.rs28
-rw-r--r--src/librustc_mir/interpret/validity.rs4
2 files changed, 16 insertions, 16 deletions
diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs
index e32abb92e21..420fe264263 100644
--- a/src/librustc_mir/interpret/memory.rs
+++ b/src/librustc_mir/interpret/memory.rs
@@ -29,7 +29,7 @@ use syntax::ast::Mutability;
 
 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 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
             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 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
     ) -> 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 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
         }
         // 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 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
         }
         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 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
                 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 => {
@@ -638,7 +638,7 @@ where
         // ensure llvm knows not to put this into immutable memory
         alloc.mutability = mutability;
         let alloc = self.tcx.intern_const_alloc(alloc);
-        self.tcx.alloc_map.lock().set_id_memory(alloc_id, alloc);
+        self.tcx.alloc_map.lock().set_alloc_id_memory(alloc_id, alloc);
         // recurse into inner allocations
         for &(_, alloc) in alloc.relocations.values() {
             // FIXME: Reusing the mutability here is likely incorrect.  It is originally
diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs
index 4f1737354ca..c7bfea82a2d 100644
--- a/src/librustc_mir/interpret/validity.rs
+++ b/src/librustc_mir/interpret/validity.rs
@@ -17,7 +17,7 @@ use rustc::ty::layout::{self, Size, Align, TyLayout, LayoutOf, VariantIdx};
 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 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>>
                             "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