about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2019-07-28 22:57:50 +0200
committerRalf Jung <post@ralfj.de>2019-07-28 22:57:50 +0200
commit647c0e06365aa4570870e78d3b29c2a8fffc0089 (patch)
treec6a62f5c1800f8508ea3d3aa91636a63c9807fce
parent74fbdb6eb8826c2a6627b666091a16691637832d (diff)
downloadrust-647c0e06365aa4570870e78d3b29c2a8fffc0089.tar.gz
rust-647c0e06365aa4570870e78d3b29c2a8fffc0089.zip
'Ref' can now be sure it gets a 'Pointer'
-rw-r--r--src/librustc_mir/interpret/step.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/librustc_mir/interpret/step.rs b/src/librustc_mir/interpret/step.rs
index 246c90ba48e..e7876c9dee9 100644
--- a/src/librustc_mir/interpret/step.rs
+++ b/src/librustc_mir/interpret/step.rs
@@ -240,8 +240,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
 
             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, _) => {