From e3ef4fdac9bc83ebc30d421d9629c9df990d04c2 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 14 Jul 2022 11:40:47 -0400 Subject: [PATCH] rename MPlaceTy::dangling to fake_alloc_zst --- compiler/rustc_const_eval/src/interpret/place.rs | 4 +++- compiler/rustc_const_eval/src/interpret/terminator.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index 84ecfbabad369..f4b11ea196757 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -188,8 +188,10 @@ impl Place { impl<'tcx, Tag: Provenance> MPlaceTy<'tcx, Tag> { /// Produces a MemPlace that works for ZST but nothing else. + /// Conceptually this is a new allocation, but it doesn't actually create an allocation so you + /// don't need to worry about memory leaks. #[inline] - pub fn dangling(layout: TyAndLayout<'tcx>) -> Self { + pub fn fake_alloc_zst(layout: TyAndLayout<'tcx>) -> Self { assert!(layout.is_zst()); let align = layout.align.abi; let ptr = Pointer::from_addr(align.bytes()); // no provenance, absolute address diff --git a/compiler/rustc_const_eval/src/interpret/terminator.rs b/compiler/rustc_const_eval/src/interpret/terminator.rs index 9ff405b993944..20122f8131c33 100644 --- a/compiler/rustc_const_eval/src/interpret/terminator.rs +++ b/compiler/rustc_const_eval/src/interpret/terminator.rs @@ -617,7 +617,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { place.to_ref(self), self.layout_of(self.tcx.mk_mut_ptr(place.layout.ty))?, ); - let ret = MPlaceTy::dangling(self.layout_of(self.tcx.types.unit)?); + let ret = MPlaceTy::fake_alloc_zst(self.layout_of(self.tcx.types.unit)?); self.eval_fn_call( FnVal::Instance(instance),