mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
Take an AllocId in intern_const_alloc_for_constprop.
This commit is contained in:
parent
e3538d11f1
commit
f08dc9be17
@ -459,10 +459,9 @@ pub fn intern_const_alloc_for_constprop<
|
||||
M: CompileTimeMachine<'mir, 'tcx, T>,
|
||||
>(
|
||||
ecx: &mut InterpCx<'mir, 'tcx, M>,
|
||||
ret: &MPlaceTy<'tcx>,
|
||||
alloc_id: AllocId,
|
||||
) -> InterpResult<'tcx, ()> {
|
||||
// Move allocation to `tcx`.
|
||||
let alloc_id = ret.ptr().provenance.unwrap();
|
||||
let Some((_, mut alloc)) = ecx.memory.alloc_map.remove(&alloc_id) else {
|
||||
// Pointer not found in local memory map. It is either a pointer to the global
|
||||
// map, or dangling.
|
||||
|
@ -61,7 +61,6 @@ use rustc_hir::def::DefKind;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_macros::newtype_index;
|
||||
use rustc_middle::mir::interpret::GlobalAlloc;
|
||||
use rustc_middle::mir::visit::*;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::layout::LayoutOf;
|
||||
@ -861,14 +860,10 @@ fn op_to_prop_const<'tcx>(
|
||||
return None;
|
||||
}
|
||||
|
||||
intern_const_alloc_for_constprop(ecx, &mplace).ok()?;
|
||||
let pointer = mplace.ptr().into_pointer_or_addr().ok()?;
|
||||
let (alloc_id, offset) = pointer.into_parts();
|
||||
match ecx.tcx.global_alloc(alloc_id) {
|
||||
GlobalAlloc::Memory(_) => return Some(ConstValue::Indirect { alloc_id, offset }),
|
||||
// Fallthrough to copying the data.
|
||||
_ => {}
|
||||
}
|
||||
intern_const_alloc_for_constprop(ecx, alloc_id).ok()?;
|
||||
return Some(ConstValue::Indirect { alloc_id, offset });
|
||||
}
|
||||
|
||||
// Everything failed: create a new allocation to hold the data.
|
||||
|
Loading…
Reference in New Issue
Block a user