Skip to content

Commit eb1ec73

Browse files
authored
Rollup merge of rust-lang#54298 - RalfJung:miri-field-align, r=eddyb
miri: correctly compute expected alignment for field This is the miri version of rust-lang#53998. A test is added by rust-lang/miri#457. r? @eddyb
2 parents 2d0262e + 56c1519 commit eb1ec73

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/librustc_mir/interpret/place.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,10 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
316316
};
317317

318318
let ptr = base.ptr.ptr_offset(offset, self)?;
319-
let align = base.align.min(field_layout.align); // only use static information
319+
let align = base.align
320+
// We do not look at `base.layout.align` nor `field_layout.align`, unlike
321+
// codegen -- mostly to see if we can get away with that
322+
.restrict_for_offset(offset); // must be last thing that happens
320323

321324
Ok(MPlaceTy { mplace: MemPlace { ptr, align, extra }, layout: field_layout })
322325
}

0 commit comments

Comments
 (0)