Skip to content

Commit

Permalink
foreign types: use size and align from layout
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Oct 13, 2018
1 parent d0c585c commit 3272c98
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/librustc_mir/interpret/validity.rs
Expand Up @@ -210,8 +210,9 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
// Make sure this is non-NULL and aligned
let (size, align) = self.size_and_align_of(place.meta, place.layout)?
// for the purpose of validity, consider foreign types to have
// alignment 1 and size 0.
.unwrap_or_else(|| (Size::ZERO, Align::from_bytes(1, 1).unwrap()));
// alignment and size determined by the layout (size will be 0,
// alignment should take attributes into account).
.unwrap_or_else(|| place.layout.size_and_align());
match self.memory.check_align(place.ptr, align) {
Ok(_) => {},
Err(err) => match err.kind {
Expand Down

0 comments on commit 3272c98

Please sign in to comment.