Move only usage of take_static_root_alloc to its definition and inline it
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
use crate::const_eval::CompileTimeEvalContext;
|
||||
use crate::const_eval::{CompileTimeEvalContext, CompileTimeInterpreter, InterpretationResult};
|
||||
use crate::interpret::{MemPlaceMeta, MemoryKind};
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_middle::mir::interpret::{AllocId, Allocation, InterpResult, Pointer};
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::{Allocation, InterpResult, Pointer};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::{
|
||||
self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
|
||||
};
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
use super::MPlaceTy;
|
||||
use super::{InterpCx, MPlaceTy};
|
||||
|
||||
/// Checks whether a type contains generic parameters which must be instantiated.
|
||||
///
|
||||
@@ -80,11 +81,15 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn take_static_root_alloc<'mir, 'tcx: 'mir>(
|
||||
ecx: &mut CompileTimeEvalContext<'mir, 'tcx>,
|
||||
alloc_id: AllocId,
|
||||
) -> Allocation {
|
||||
ecx.memory.alloc_map.swap_remove(&alloc_id).unwrap().1
|
||||
impl<'tcx> InterpretationResult<'tcx> for mir::interpret::ConstAllocation<'tcx> {
|
||||
fn make_result<'mir>(
|
||||
mplace: MPlaceTy<'tcx>,
|
||||
ecx: &mut InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
|
||||
) -> Self {
|
||||
let alloc_id = mplace.ptr().provenance.unwrap().alloc_id();
|
||||
let alloc = ecx.memory.alloc_map.swap_remove(&alloc_id).unwrap().1;
|
||||
ecx.tcx.mk_const_alloc(alloc)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn create_static_alloc<'mir, 'tcx: 'mir>(
|
||||
|
||||
Reference in New Issue
Block a user