diff options
| author | Ralf Jung <post@ralfj.de> | 2022-07-14 11:40:47 -0400 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2022-07-14 11:40:47 -0400 |
| commit | e3ef4fdac9bc83ebc30d421d9629c9df990d04c2 (patch) | |
| tree | dbff7ce5049f75c9264a03a94ffa604df2cd5b12 /compiler/rustc_const_eval/src/interpret | |
| parent | 874a130ca01eb8a915b3ba0898aaeff35578758a (diff) | |
| download | rust-e3ef4fdac9bc83ebc30d421d9629c9df990d04c2.tar.gz rust-e3ef4fdac9bc83ebc30d421d9629c9df990d04c2.zip | |
rename MPlaceTy::dangling to fake_alloc_zst
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/place.rs | 4 | ||||
| -rw-r--r-- | 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 84ecfbabad3..f4b11ea1967 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -188,8 +188,10 @@ impl<Tag: Provenance> Place<Tag> { 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 9ff405b9939..20122f8131c 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), |
