]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/interpret/eval_context.rs
Simplify `force_allocation_maybe_sized`
[rust.git] / src / librustc_mir / interpret / eval_context.rs
index ad2af8d7aca52aa2d612f6e183dc44b7a17e446c..5ba9dcd3aa5c8484c9ce7e4e3c329524733919cc 100644 (file)
@@ -118,7 +118,7 @@ pub struct LocalState<'tcx, Tag = (), Id = AllocId> {
 }
 
 /// Current value of a local variable
-#[derive(Clone, PartialEq, Eq, Debug, HashStable)] // Miri debug-prints these
+#[derive(Copy, Clone, PartialEq, Eq, Debug, HashStable)] // Miri debug-prints these
 pub enum LocalValue<Tag = (), Id = AllocId> {
     /// This local is not currently alive, and cannot be used at all.
     Dead,
@@ -743,7 +743,9 @@ pub(super) fn deallocate_local(
         // FIXME: should we tell the user that there was a local which was never written to?
         if let LocalValue::Live(Operand::Indirect(MemPlace { ptr, .. })) = local {
             trace!("deallocating local");
-            let ptr = ptr.to_ptr()?;
+            // All locals have a backing allocation, even if the allocation is empty
+            // due to the local having ZST type.
+            let ptr = ptr.assert_ptr();
             if log_enabled!(::log::Level::Trace) {
                 self.memory.dump_alloc(ptr.alloc_id);
             }