Skip to content

Commit 647c0e0

Browse files
committed
'Ref' can now be sure it gets a 'Pointer'
1 parent 74fbdb6 commit 647c0e0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/librustc_mir/interpret/step.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
240240

241241
Ref(_, _, ref place) => {
242242
let src = self.eval_place(place)?;
243-
let val = self.force_allocation(src)?;
244-
self.write_immediate(val.to_ref(), dest)?;
243+
let place = self.force_allocation(src)?;
244+
if place.layout.size.bytes() > 0 {
245+
// definitely not a ZST
246+
assert!(place.ptr.is_ptr(), "non-ZST places should be normalized to `Pointer`");
247+
}
248+
self.write_immediate(place.to_ref(), dest)?;
245249
}
246250

247251
NullaryOp(mir::NullOp::Box, _) => {

0 commit comments

Comments
 (0)