]> git.lizzy.rs Git - rust.git/commitdiff
'Ref' can now be sure it gets a 'Pointer'
authorRalf Jung <post@ralfj.de>
Sun, 28 Jul 2019 20:57:50 +0000 (22:57 +0200)
committerRalf Jung <post@ralfj.de>
Sun, 28 Jul 2019 20:57:50 +0000 (22:57 +0200)
src/librustc_mir/interpret/step.rs

index 246c90ba48e3aa3661ca61a81dbaf4ea932a0a0a..e7876c9dee904efd27bbf08a2605d00d198450d8 100644 (file)
@@ -240,8 +240,12 @@ fn eval_rvalue_into_place(
 
             Ref(_, _, ref place) => {
                 let src = self.eval_place(place)?;
-                let val = self.force_allocation(src)?;
-                self.write_immediate(val.to_ref(), dest)?;
+                let place = self.force_allocation(src)?;
+                if place.layout.size.bytes() > 0 {
+                    // definitely not a ZST
+                    assert!(place.ptr.is_ptr(), "non-ZST places should be normalized to `Pointer`");
+                }
+                self.write_immediate(place.to_ref(), dest)?;
             }
 
             NullaryOp(mir::NullOp::Box, _) => {