Skip to content

Commit 03b8928

Browse files
committed
Check the correct arena
1 parent 9654ae9 commit 03b8928

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/libarena/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ impl<T> Default for TypedArena<T> {
119119
}
120120

121121
impl<T> TypedArena<T> {
122+
pub fn in_arena(&self, ptr: *const T) -> bool {
123+
let ptr = ptr as *const T as *mut T;
124+
125+
self.chunks.borrow().iter().any(|chunk| chunk.start() <= ptr && ptr < chunk.end())
126+
}
122127
/// Allocates an object in the `TypedArena`, returning a reference to it.
123128
#[inline]
124129
pub fn alloc(&self, object: T) -> &mut T {

src/librustc/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,7 @@ nop_list_lift!{Kind<'a> => Kind<'tcx>}
17621762
impl<'a, 'tcx> Lift<'tcx> for &'a mir::interpret::Allocation {
17631763
type Lifted = &'tcx mir::interpret::Allocation;
17641764
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
1765-
assert!(tcx.global_interners.arena.in_arena(*self as *const _));
1765+
assert!(tcx.global_arenas.const_allocs.in_arena(*self as *const _));
17661766
Some(unsafe { mem::transmute(*self) })
17671767
}
17681768
}

0 commit comments

Comments
 (0)