Skip to content

Commit 6b26640

Browse files
committed
remove unnecessary deallocate_local hack
1 parent c8baac5 commit 6b26640

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

compiler/rustc_mir/src/interpret/eval_context.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use rustc_span::{Pos, Span};
1818
use rustc_target::abi::{Align, HasDataLayout, LayoutOf, Size, TargetDataLayout};
1919

2020
use super::{
21-
Immediate, MPlaceTy, Machine, MemPlace, MemPlaceMeta, Memory, Operand, Place, PlaceTy,
22-
ScalarMaybeUninit, StackPopJump,
21+
Immediate, MPlaceTy, Machine, MemPlace, MemPlaceMeta, Memory, MemoryKind, Operand, Place,
22+
PlaceTy, ScalarMaybeUninit, StackPopJump,
2323
};
2424
use crate::transform::validate::equal_up_to_regions;
2525
use crate::util::storage::AlwaysLiveLocals;
@@ -900,7 +900,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
900900
// due to the local having ZST type.
901901
let ptr = ptr.assert_ptr();
902902
trace!("deallocating local: {:?}", self.memory.dump_alloc(ptr.alloc_id));
903-
self.memory.deallocate_local(ptr)?;
903+
self.memory.deallocate(ptr, None, MemoryKind::Stack)?;
904904
};
905905
Ok(())
906906
}

compiler/rustc_mir/src/interpret/memory.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -276,17 +276,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
276276
Ok(new_ptr)
277277
}
278278

279-
/// Deallocate a local, or do nothing if that local has been made into a global.
280-
pub fn deallocate_local(&mut self, ptr: Pointer<M::PointerTag>) -> InterpResult<'tcx> {
281-
// The allocation might be already removed by global interning.
282-
// This can only really happen in the CTFE instance, not in miri.
283-
if self.alloc_map.contains_key(&ptr.alloc_id) {
284-
self.deallocate(ptr, None, MemoryKind::Stack)
285-
} else {
286-
Ok(())
287-
}
288-
}
289-
290279
pub fn deallocate(
291280
&mut self,
292281
ptr: Pointer<M::PointerTag>,
@@ -1110,7 +1099,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
11101099
}
11111100

11121101
// now fill in all the "init" data
1113-
dest_alloc.mark_compressed_init_range(&compressed, alloc_range(dest.offset, size), num_copies);
1102+
dest_alloc.mark_compressed_init_range(
1103+
&compressed,
1104+
alloc_range(dest.offset, size),
1105+
num_copies,
1106+
);
11141107
// copy the relocations to the destination
11151108
dest_alloc.mark_relocation_range(relocations);
11161109

0 commit comments

Comments
 (0)