diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-12-28 21:09:47 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-01-01 20:06:50 +0100 |
| commit | 03b892860da5aff7a10cf4ca1364dbcacb95bfcd (patch) | |
| tree | ed0d64da7f4263678ae76d077cf2fe2894a06f19 | |
| parent | 9654ae9c9973253e0e87bff9fd8f79be87492c64 (diff) | |
| download | rust-03b892860da5aff7a10cf4ca1364dbcacb95bfcd.tar.gz rust-03b892860da5aff7a10cf4ca1364dbcacb95bfcd.zip | |
Check the correct arena
| -rw-r--r-- | src/libarena/lib.rs | 5 | ||||
| -rw-r--r-- | src/librustc/ty/context.rs | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index b40e905620d..9f9ded51e37 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -119,6 +119,11 @@ impl<T> Default for TypedArena<T> { } impl<T> TypedArena<T> { + pub fn in_arena(&self, ptr: *const T) -> bool { + let ptr = ptr as *const T as *mut T; + + self.chunks.borrow().iter().any(|chunk| chunk.start() <= ptr && ptr < chunk.end()) + } /// Allocates an object in the `TypedArena`, returning a reference to it. #[inline] pub fn alloc(&self, object: T) -> &mut T { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 74fa5363fb2..6c377941dad 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1762,7 +1762,7 @@ nop_list_lift!{Kind<'a> => Kind<'tcx>} impl<'a, 'tcx> Lift<'tcx> for &'a mir::interpret::Allocation { type Lifted = &'tcx mir::interpret::Allocation; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> { - assert!(tcx.global_interners.arena.in_arena(*self as *const _)); + assert!(tcx.global_arenas.const_allocs.in_arena(*self as *const _)); Some(unsafe { mem::transmute(*self) }) } } |
