]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #55888 - RalfJung:alloc-extra, r=oli-obk
authorkennytm <kennytm@gmail.com>
Tue, 13 Nov 2018 05:03:21 +0000 (13:03 +0800)
committerkennytm <kennytm@gmail.com>
Tue, 13 Nov 2018 11:20:55 +0000 (19:20 +0800)
miri: for uniformity, also move memory_deallocated to AllocationExtra

r? @oli-obk

src/librustc/mir/interpret/allocation.rs
src/librustc_mir/interpret/machine.rs
src/librustc_mir/interpret/memory.rs

index e55997099c82b92c9312abd9755e84d5b1df5893..cc92b63256c1ff7c6b8e3259f29da401dd59bac8 100644 (file)
@@ -65,6 +65,17 @@ fn memory_written(
     ) -> EvalResult<'tcx> {
         Ok(())
     }
+
+    /// Hook for performing extra checks on a memory deallocation.
+    /// `size` will be the size of the allocation.
+    #[inline]
+    fn memory_deallocated(
+        _alloc: &mut Allocation<Tag, Self>,
+        _ptr: Pointer<Tag>,
+        _size: Size,
+    ) -> EvalResult<'tcx> {
+        Ok(())
+    }
 }
 
 impl AllocationExtra<()> for () {}
index 047996777ea968907592791c4c3701049ab8670a..1efd7ca7f89738f658a42727d8df56f71f627b2d 100644 (file)
@@ -17,7 +17,7 @@
 
 use rustc::hir::{self, def_id::DefId};
 use rustc::mir;
-use rustc::ty::{self, layout::{Size, TyLayout}, query::TyCtxtAt};
+use rustc::ty::{self, layout::TyLayout, query::TyCtxtAt};
 
 use super::{
     Allocation, AllocId, EvalResult, Scalar, AllocationExtra,
@@ -174,16 +174,6 @@ fn box_alloc(
         dest: PlaceTy<'tcx, Self::PointerTag>,
     ) -> EvalResult<'tcx>;
 
-    /// Hook for performing extra checks when memory gets deallocated.
-    #[inline]
-    fn memory_deallocated(
-        _alloc: &mut Allocation<Self::PointerTag, Self::AllocExtra>,
-        _ptr: Pointer<Self::PointerTag>,
-        _size: Size,
-    ) -> EvalResult<'tcx> {
-        Ok(())
-    }
-
     /// Add the tag for a newly allocated pointer.
     fn tag_new_allocation(
         ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>,
index 10bc984a447a3c17d74a12bd7eaf4ce927625196..e125927e7d2732ea8c0c97d1c7b4746371076065 100644 (file)
@@ -225,7 +225,7 @@ pub fn deallocate(
 
         // Let the machine take some extra action
         let size = Size::from_bytes(alloc.bytes.len() as u64);
-        M::memory_deallocated(&mut alloc, ptr, size)?;
+        AllocationExtra::memory_deallocated(&mut alloc, ptr, size)?;
 
         // Don't forget to remember size and align of this now-dead allocation
         let old = self.dead_alloc_map.insert(