]> git.lizzy.rs Git - rust.git/commitdiff
foreign types: use size and align from layout
authorRalf Jung <post@ralfj.de>
Wed, 10 Oct 2018 07:11:38 +0000 (09:11 +0200)
committerRalf Jung <post@ralfj.de>
Sat, 13 Oct 2018 07:09:03 +0000 (09:09 +0200)
src/librustc_mir/interpret/validity.rs

index e2fa4b15f819d556f6853dd0eb7299cc1df72a30..59df61f2a6f93046435afa4aa50aa367c714c9bc 100644 (file)
@@ -210,8 +210,9 @@ fn validate_primitive_type(
                     // 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 {