@@ -333,7 +333,7 @@ where
333
333
let val = self . read_immediate ( src) ?;
334
334
trace ! ( "deref to {} on {:?}" , val. layout. ty, * val) ;
335
335
let place = self . ref_to_mplace ( val) ?;
336
- self . mplace_access_checked ( place)
336
+ self . mplace_access_checked ( place, None )
337
337
}
338
338
339
339
/// Check if the given place is good for memory access with the given
@@ -358,15 +358,20 @@ where
358
358
359
359
/// Return the "access-checked" version of this `MPlace`, where for non-ZST
360
360
/// this is definitely a `Pointer`.
361
+ ///
362
+ /// `force_align` must only be used when correct alignment does not matter,
363
+ /// like in Stacked Borrows.
361
364
pub fn mplace_access_checked (
362
365
& self ,
363
366
mut place : MPlaceTy < ' tcx , M :: PointerTag > ,
367
+ force_align : Option < Align > ,
364
368
) -> InterpResult < ' tcx , MPlaceTy < ' tcx , M :: PointerTag > > {
365
369
let ( size, align) = self
366
370
. size_and_align_of_mplace ( place) ?
367
371
. unwrap_or ( ( place. layout . size , place. layout . align . abi ) ) ;
368
372
assert ! ( place. mplace. align <= align, "dynamic alignment less strict than static one?" ) ;
369
- place. mplace . align = align; // maximally strict checking
373
+ // Check (stricter) dynamic alignment, unless forced otherwise.
374
+ place. mplace . align = force_align. unwrap_or ( align) ;
370
375
// When dereferencing a pointer, it must be non-NULL, aligned, and live.
371
376
if let Some ( ptr) = self . check_mplace_access ( place, Some ( size) ) ? {
372
377
place. mplace . ptr = ptr. into ( ) ;
0 commit comments