Skip to content

Commit 56c1519

Browse files
committed
miri: correctly compute expected alignment for field
1 parent f1aefb4 commit 56c1519

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)