diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-11-04 16:01:50 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-11-08 14:52:02 +0100 |
| commit | 5d58a036de126f2d0900376be5da666de6c9f770 (patch) | |
| tree | e639b18338f9052d971806ec04be76325d2c0176 | |
| parent | 769ee79a6978226a3ae788524b3276e71ac000d4 (diff) | |
| download | rust-5d58a036de126f2d0900376be5da666de6c9f770.tar.gz rust-5d58a036de126f2d0900376be5da666de6c9f770.zip | |
Give `AllocationExtra`s access to their entire `Allocation`
| -rw-r--r-- | src/librustc/mir/interpret/allocation.rs | 8 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/memory.rs | 4 |
2 files changed, 4 insertions, 8 deletions
diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs index cd8064adf52..e55997099c8 100644 --- a/src/librustc/mir/interpret/allocation.rs +++ b/src/librustc/mir/interpret/allocation.rs @@ -49,7 +49,7 @@ pub trait AllocationExtra<Tag>: ::std::fmt::Debug + Default + Clone { /// need to mutate. #[inline] fn memory_read( - &self, + _alloc: &Allocation<Tag, Self>, _ptr: Pointer<Tag>, _size: Size, ) -> EvalResult<'tcx> { @@ -57,13 +57,9 @@ pub trait AllocationExtra<Tag>: ::std::fmt::Debug + Default + Clone { } /// Hook for performing extra checks on a memory write access. - /// - /// Takes read-only access to the allocation so we can keep all the memory read - /// operations take `&self`. Use a `RefCell` in `AllocExtra` if you - /// need to mutate. #[inline] fn memory_written( - &mut self, + _alloc: &mut Allocation<Tag, Self>, _ptr: Pointer<Tag>, _size: Size, ) -> EvalResult<'tcx> { diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index ef2510dec35..10bc984a447 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -637,7 +637,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { } let alloc = self.get(ptr.alloc_id)?; - AllocationExtra::memory_read(&alloc.extra, ptr, size)?; + AllocationExtra::memory_read(alloc, ptr, size)?; assert_eq!(ptr.offset.bytes() as usize as u64, ptr.offset.bytes()); assert_eq!(size.bytes() as usize as u64, size.bytes()); @@ -683,7 +683,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { self.clear_relocations(ptr, size)?; let alloc = self.get_mut(ptr.alloc_id)?; - AllocationExtra::memory_written(&mut alloc.extra, ptr, size)?; + AllocationExtra::memory_written(alloc, ptr, size)?; assert_eq!(ptr.offset.bytes() as usize as u64, ptr.offset.bytes()); assert_eq!(size.bytes() as usize as u64, size.bytes()); |
