Skip to content

Commit e3ef4fd

Browse files
committed
rename MPlaceTy::dangling to fake_alloc_zst
1 parent 874a130 commit e3ef4fd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

compiler/rustc_const_eval/src/interpret/place.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,10 @@ impl<Tag: Provenance> Place<Tag> {
188188

189189
impl<'tcx, Tag: Provenance> MPlaceTy<'tcx, Tag> {
190190
/// Produces a MemPlace that works for ZST but nothing else.
191+
/// Conceptually this is a new allocation, but it doesn't actually create an allocation so you
192+
/// don't need to worry about memory leaks.
191193
#[inline]
192-
pub fn dangling(layout: TyAndLayout<'tcx>) -> Self {
194+
pub fn fake_alloc_zst(layout: TyAndLayout<'tcx>) -> Self {
193195
assert!(layout.is_zst());
194196
let align = layout.align.abi;
195197
let ptr = Pointer::from_addr(align.bytes()); // no provenance, absolute address

compiler/rustc_const_eval/src/interpret/terminator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
617617
place.to_ref(self),
618618
self.layout_of(self.tcx.mk_mut_ptr(place.layout.ty))?,
619619
);
620-
let ret = MPlaceTy::dangling(self.layout_of(self.tcx.types.unit)?);
620+
let ret = MPlaceTy::fake_alloc_zst(self.layout_of(self.tcx.types.unit)?);
621621

622622
self.eval_fn_call(
623623
FnVal::Instance(instance),

0 commit comments

Comments
 (0)