diff --git a/src/lib.rs b/src/lib.rs index c910911f5762..1ff29828dab4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -264,8 +264,10 @@ type MiriEvalContext<'a, 'mir, 'tcx> = EvalContext<'a, 'mir, 'tcx, Evaluator<'tc impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> { type MemoryKinds = MiriMemoryKind; + type AllocExtra = stacked_borrows::Stacks; type PointerTag = Borrow; + const ENABLE_PTR_TRACKING_HOOKS: bool = true; type MemoryMap = MonoHashMap, Allocation)>; @@ -433,22 +435,6 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> { alloc.extra.memory_deallocated(ptr) } - /*/// Hook for when a reference is cast to a raw pointer - #[inline(always)] - fn ref_to_raw_cast( - ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>, - ptr: Pointer, - ptr_ty: Ty<'tcx>, - size: Size, - ) -> EvalResult<'tcx> { - if !ecx.machine.validate { - // No tracking. - Ok(()) - } else { - ecx.ref_to_raw_cast(ptr, ptr_ty, size) - } - }*/ - #[inline(always)] fn tag_reference( ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>, diff --git a/src/stacked_borrows.rs b/src/stacked_borrows.rs index e4d2289bf34c..19d5c723d403 100644 --- a/src/stacked_borrows.rs +++ b/src/stacked_borrows.rs @@ -253,13 +253,6 @@ pub trait EvalContextExt<'tcx> { ptr: Pointer, ptr_ty: Ty<'tcx>, ) -> EvalResult<'tcx, Borrow>; - - fn ref_to_raw_cast( - &mut self, - ptr: Pointer, - ptr_ty: Ty<'tcx>, - size: Size, - ) -> EvalResult<'tcx>; } impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, 'tcx> { @@ -311,23 +304,4 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, ' ptr.tag }) } - - fn ref_to_raw_cast( - &mut self, - ptr: Pointer, - _ptr_ty: Ty<'tcx>, - size: Size, - ) -> EvalResult<'tcx> { - trace!("ref_to_raw_cast: Escaping {:?}", ptr); - - // Make sure this reference is not dangling or so - self.memory.check_bounds(ptr, size, false)?; - - // Update the stacks. We cannot use `get_mut` becuse this might be immutable - // memory. - let alloc = self.memory.get(ptr.alloc_id).expect("We checked that the ptr is fine!"); - alloc.extra.reborrow(ptr, size, Borrow::Mut(Mut::Raw))?; - - Ok(()) - } }