]> git.lizzy.rs Git - rust.git/commitdiff
miri: correctly compute expected alignment for field
authorRalf Jung <post@ralfj.de>
Mon, 17 Sep 2018 16:05:17 +0000 (18:05 +0200)
committerRalf Jung <post@ralfj.de>
Mon, 17 Sep 2018 16:05:17 +0000 (18:05 +0200)
src/librustc_mir/interpret/place.rs

index e3f7f26f53efda786f55b8045ed9015dca092228..0f03aa097c9dfdb64ff8e0fef412f01e8a566fed 100644 (file)
@@ -316,7 +316,10 @@ pub fn mplace_field(
         };
 
         let ptr = base.ptr.ptr_offset(offset, self)?;
-        let align = base.align.min(field_layout.align); // only use static information
+        let align = base.align
+            // We do not look at `base.layout.align` nor `field_layout.align`, unlike
+            // codegen -- mostly to see if we can get away with that
+            .restrict_for_offset(offset); // must be last thing that happens
 
         Ok(MPlaceTy { mplace: MemPlace { ptr, align, extra }, layout: field_layout })
     }