@@ -271,8 +271,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
271271 /// Visits the memory covered by `place`, sensitive to freezing: the 2nd parameter
272272 /// of `action` will be true if this is frozen, false if this is in an `UnsafeCell`.
273273 /// The range is relative to `place`.
274- ///
275- /// Assumes that the `place` has a proper pointer in it.
276274 fn visit_freeze_sensitive (
277275 & self ,
278276 place : & MPlaceTy < ' tcx , Tag > ,
@@ -290,33 +288,30 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
290288 // Store how far we proceeded into the place so far. Everything to the left of
291289 // this offset has already been handled, in the sense that the frozen parts
292290 // have had `action` called on them.
293- let ptr = place. ptr . into_pointer_or_addr ( ) . unwrap ( ) ;
294- let start_offset = ptr. into_parts ( ) . 1 as Size ; // we just compare offsets, the abs. value never matters
295- let mut cur_offset = start_offset;
291+ let start_addr = place. ptr . addr ( ) ;
292+ let mut cur_addr = start_addr;
296293 // Called when we detected an `UnsafeCell` at the given offset and size.
297294 // Calls `action` and advances `cur_ptr`.
298- let mut unsafe_cell_action = |unsafe_cell_ptr : Pointer < Option < Tag > > ,
295+ let mut unsafe_cell_action = |unsafe_cell_ptr : & Pointer < Option < Tag > > ,
299296 unsafe_cell_size : Size | {
300- let unsafe_cell_ptr = unsafe_cell_ptr. into_pointer_or_addr ( ) . unwrap ( ) ;
301- debug_assert_eq ! ( unsafe_cell_ptr. provenance, ptr. provenance) ;
302297 // We assume that we are given the fields in increasing offset order,
303298 // and nothing else changes.
304- let unsafe_cell_offset = unsafe_cell_ptr. into_parts ( ) . 1 as Size ; // we just compare offsets, the abs. value never matters
305- assert ! ( unsafe_cell_offset >= cur_offset ) ;
306- let frozen_size = unsafe_cell_offset - cur_offset ;
299+ let unsafe_cell_addr = unsafe_cell_ptr. addr ( ) ;
300+ assert ! ( unsafe_cell_addr >= cur_addr ) ;
301+ let frozen_size = unsafe_cell_addr - cur_addr ;
307302 // Everything between the cur_ptr and this `UnsafeCell` is frozen.
308303 if frozen_size != Size :: ZERO {
309- action ( alloc_range ( cur_offset - start_offset , frozen_size) , /*frozen*/ true ) ?;
304+ action ( alloc_range ( cur_addr - start_addr , frozen_size) , /*frozen*/ true ) ?;
310305 }
311- cur_offset += frozen_size;
306+ cur_addr += frozen_size;
312307 // This `UnsafeCell` is NOT frozen.
313308 if unsafe_cell_size != Size :: ZERO {
314309 action (
315- alloc_range ( cur_offset - start_offset , unsafe_cell_size) ,
310+ alloc_range ( cur_addr - start_addr , unsafe_cell_size) ,
316311 /*frozen*/ false ,
317312 ) ?;
318313 }
319- cur_offset += unsafe_cell_size;
314+ cur_addr += unsafe_cell_size;
320315 // Done
321316 Ok ( ( ) )
322317 } ;
@@ -334,7 +329,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
334329 . unwrap_or_else ( || place. layout . size ) ;
335330 // Now handle this `UnsafeCell`, unless it is empty.
336331 if unsafe_cell_size != Size :: ZERO {
337- unsafe_cell_action ( place. ptr , unsafe_cell_size)
332+ unsafe_cell_action ( & place. ptr , unsafe_cell_size)
338333 } else {
339334 Ok ( ( ) )
340335 }
@@ -344,7 +339,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
344339 }
345340 // The part between the end_ptr and the end of the place is also frozen.
346341 // So pretend there is a 0-sized `UnsafeCell` at the end.
347- unsafe_cell_action ( place. ptr . wrapping_offset ( size, this) , Size :: ZERO ) ?;
342+ unsafe_cell_action ( & place. ptr . offset ( size, this) ? , Size :: ZERO ) ?;
348343 // Done!
349344 return Ok ( ( ) ) ;
350345
@@ -428,9 +423,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
428423 let mut places =
429424 fields. collect :: < InterpResult < ' tcx , Vec < MPlaceTy < ' tcx , Tag > > > > ( ) ?;
430425 // we just compare offsets, the abs. value never matters
431- places. sort_by_key ( |place| {
432- place. ptr . into_pointer_or_addr ( ) . unwrap ( ) . into_parts ( ) . 1 as Size
433- } ) ;
426+ places. sort_by_key ( |place| place. ptr . addr ( ) ) ;
434427 self . walk_aggregate ( place, places. into_iter ( ) . map ( Ok ) )
435428 }
436429 FieldsShape :: Union { .. } | FieldsShape :: Primitive => {
@@ -777,6 +770,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
777770 /// Mark a machine allocation that was just created as immutable.
778771 fn mark_immutable ( & mut self , mplace : & MemPlace < Tag > ) {
779772 let this = self . eval_context_mut ( ) ;
773+ // This got just allocated, so there definitely is a pointer here.
780774 this. alloc_mark_immutable ( mplace. ptr . into_pointer_or_addr ( ) . unwrap ( ) . provenance . alloc_id )
781775 . unwrap ( ) ;
782776 }
0 commit comments