Skip to content

Commit 3272c98

Browse files
committed
foreign types: use size and align from layout
1 parent d0c585c commit 3272c98

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/librustc_mir/interpret/validity.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,9 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
210210
// Make sure this is non-NULL and aligned
211211
let (size, align) = self.size_and_align_of(place.meta, place.layout)?
212212
// for the purpose of validity, consider foreign types to have
213-
// alignment 1 and size 0.
214-
.unwrap_or_else(|| (Size::ZERO, Align::from_bytes(1, 1).unwrap()));
213+
// alignment and size determined by the layout (size will be 0,
214+
// alignment should take attributes into account).
215+
.unwrap_or_else(|| place.layout.size_and_align());
215216
match self.memory.check_align(place.ptr, align) {
216217
Ok(_) => {},
217218
Err(err) => match err.kind {

0 commit comments

Comments
 (0)