]> git.lizzy.rs Git - rust.git/commitdiff
for uniformity, also move memory_deallocated to AllocationExtra
authorRalf Jung <post@ralfj.de>
Mon, 12 Nov 2018 07:39:13 +0000 (08:39 +0100)
committerRalf Jung <post@ralfj.de>
Mon, 12 Nov 2018 07:39:13 +0000 (08:39 +0100)
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..4f677b086d420a34dd066c2679efc86532f19759 100644 (file)
@@ -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(