Skip to content

Commit 488ce66

Browse files
committed
Take an AllocId in intern_const_alloc_for_constprop.
1 parent a0bc4fc commit 488ce66

File tree

2 files changed

+3
-9
lines changed
  • compiler

2 files changed

+3
-9
lines changed

compiler/rustc_const_eval/src/interpret/intern.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,9 @@ pub fn intern_const_alloc_for_constprop<
459459
M: CompileTimeMachine<'mir, 'tcx, T>,
460460
>(
461461
ecx: &mut InterpCx<'mir, 'tcx, M>,
462-
ret: &MPlaceTy<'tcx>,
462+
alloc_id: AllocId,
463463
) -> InterpResult<'tcx, ()> {
464464
// Move allocation to `tcx`.
465-
let alloc_id = ret.ptr().provenance.unwrap();
466465
let Some((_, mut alloc)) = ecx.memory.alloc_map.remove(&alloc_id) else {
467466
// Pointer not found in local memory map. It is either a pointer to the global
468467
// map, or dangling.

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ use rustc_hir::def::DefKind;
6161
use rustc_index::bit_set::BitSet;
6262
use rustc_index::IndexVec;
6363
use rustc_macros::newtype_index;
64-
use rustc_middle::mir::interpret::GlobalAlloc;
6564
use rustc_middle::mir::visit::*;
6665
use rustc_middle::mir::*;
6766
use rustc_middle::ty::layout::LayoutOf;
@@ -861,14 +860,10 @@ fn op_to_prop_const<'tcx>(
861860
return None;
862861
}
863862

864-
intern_const_alloc_for_constprop(ecx, &mplace).ok()?;
865863
let pointer = mplace.ptr().into_pointer_or_addr().ok()?;
866864
let (alloc_id, offset) = pointer.into_parts();
867-
match ecx.tcx.global_alloc(alloc_id) {
868-
GlobalAlloc::Memory(_) => return Some(ConstValue::Indirect { alloc_id, offset }),
869-
// Fallthrough to copying the data.
870-
_ => {}
871-
}
865+
intern_const_alloc_for_constprop(ecx, alloc_id).ok()?;
866+
return Some(ConstValue::Indirect { alloc_id, offset });
872867
}
873868

874869
// Everything failed: create a new allocation to hold the data.

0 commit comments

Comments
 (0)