Take an AllocId in intern_const_alloc_for_constprop.
This commit is contained in:
parent
e3538d11f1
commit
f08dc9be17
2 changed files with 3 additions and 9 deletions
|
@ -459,10 +459,9 @@ pub fn intern_const_alloc_for_constprop<
|
||||||
M: CompileTimeMachine<'mir, 'tcx, T>,
|
M: CompileTimeMachine<'mir, 'tcx, T>,
|
||||||
>(
|
>(
|
||||||
ecx: &mut InterpCx<'mir, 'tcx, M>,
|
ecx: &mut InterpCx<'mir, 'tcx, M>,
|
||||||
ret: &MPlaceTy<'tcx>,
|
alloc_id: AllocId,
|
||||||
) -> InterpResult<'tcx, ()> {
|
) -> InterpResult<'tcx, ()> {
|
||||||
// Move allocation to `tcx`.
|
// Move allocation to `tcx`.
|
||||||
let alloc_id = ret.ptr().provenance.unwrap();
|
|
||||||
let Some((_, mut alloc)) = ecx.memory.alloc_map.remove(&alloc_id) else {
|
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
|
// Pointer not found in local memory map. It is either a pointer to the global
|
||||||
// map, or dangling.
|
// map, or dangling.
|
||||||
|
|
|
@ -61,7 +61,6 @@ use rustc_hir::def::DefKind;
|
||||||
use rustc_index::bit_set::BitSet;
|
use rustc_index::bit_set::BitSet;
|
||||||
use rustc_index::IndexVec;
|
use rustc_index::IndexVec;
|
||||||
use rustc_macros::newtype_index;
|
use rustc_macros::newtype_index;
|
||||||
use rustc_middle::mir::interpret::GlobalAlloc;
|
|
||||||
use rustc_middle::mir::visit::*;
|
use rustc_middle::mir::visit::*;
|
||||||
use rustc_middle::mir::*;
|
use rustc_middle::mir::*;
|
||||||
use rustc_middle::ty::layout::LayoutOf;
|
use rustc_middle::ty::layout::LayoutOf;
|
||||||
|
@ -861,14 +860,10 @@ fn op_to_prop_const<'tcx>(
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
intern_const_alloc_for_constprop(ecx, &mplace).ok()?;
|
|
||||||
let pointer = mplace.ptr().into_pointer_or_addr().ok()?;
|
let pointer = mplace.ptr().into_pointer_or_addr().ok()?;
|
||||||
let (alloc_id, offset) = pointer.into_parts();
|
let (alloc_id, offset) = pointer.into_parts();
|
||||||
match ecx.tcx.global_alloc(alloc_id) {
|
intern_const_alloc_for_constprop(ecx, alloc_id).ok()?;
|
||||||
GlobalAlloc::Memory(_) => return Some(ConstValue::Indirect { alloc_id, offset }),
|
return Some(ConstValue::Indirect { alloc_id, offset });
|
||||||
// Fallthrough to copying the data.
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everything failed: create a new allocation to hold the data.
|
// Everything failed: create a new allocation to hold the data.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue