Skip to content

Commit

Permalink
rename MPlaceTy::dangling to fake_alloc_zst
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jul 14, 2022
1 parent 874a130 commit e3ef4fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion compiler/rustc_const_eval/src/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit e3ef4fd

Please sign in to comment.