Skip to content

Commit 71ef9e2

Browse files
committed
Move InterpCx into eval_in_interpreter
1 parent 31fa142 commit 71ef9e2

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,15 @@ pub fn eval_static_initializer_provider<'tcx>(
282282

283283
let instance = ty::Instance::mono(tcx, def_id.to_def_id());
284284
let cid = rustc_middle::mir::interpret::GlobalId { instance, promoted: None };
285-
let mut ecx = InterpCx::new(
285+
let ecx = InterpCx::new(
286286
tcx,
287287
tcx.def_span(def_id),
288288
ty::ParamEnv::reveal_all(),
289289
// Statics (and promoteds inside statics) may access other statics, because unlike consts
290290
// they do not have to behave "as if" they were evaluated at runtime.
291291
CompileTimeInterpreter::new(CanAccessMutGlobal::Yes, CheckAlignment::Error),
292292
);
293-
eval_in_interpreter(&mut ecx, cid, true)
293+
eval_in_interpreter(ecx, cid, true)
294294
}
295295

296296
pub trait InterpretationResult<'tcx> {
@@ -299,14 +299,14 @@ pub trait InterpretationResult<'tcx> {
299299
/// evaluation query.
300300
fn make_result<'mir>(
301301
mplace: MPlaceTy<'tcx>,
302-
ecx: &mut InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
302+
ecx: InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
303303
) -> Self;
304304
}
305305

306306
impl<'tcx> InterpretationResult<'tcx> for ConstAlloc<'tcx> {
307307
fn make_result<'mir>(
308308
mplace: MPlaceTy<'tcx>,
309-
_ecx: &mut InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
309+
_ecx: InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
310310
) -> Self {
311311
ConstAlloc { alloc_id: mplace.ptr().provenance.unwrap().alloc_id(), ty: mplace.layout.ty }
312312
}
@@ -339,7 +339,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
339339
let def = cid.instance.def.def_id();
340340
let is_static = tcx.is_static(def);
341341

342-
let mut ecx = InterpCx::new(
342+
let ecx = InterpCx::new(
343343
tcx,
344344
tcx.def_span(def),
345345
key.param_env,
@@ -349,19 +349,19 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
349349
// so we have to reject reading mutable global memory.
350350
CompileTimeInterpreter::new(CanAccessMutGlobal::from(is_static), CheckAlignment::Error),
351351
);
352-
eval_in_interpreter(&mut ecx, cid, is_static)
352+
eval_in_interpreter(ecx, cid, is_static)
353353
}
354354

355355
fn eval_in_interpreter<'mir, 'tcx, R: InterpretationResult<'tcx>>(
356-
ecx: &mut InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
356+
mut ecx: InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
357357
cid: GlobalId<'tcx>,
358358
is_static: bool,
359359
) -> Result<R, ErrorHandled> {
360360
// `is_static` just means "in static", it could still be a promoted!
361361
debug_assert_eq!(is_static, ecx.tcx.static_mutability(cid.instance.def_id()).is_some());
362362

363363
let res = ecx.load_mir(cid.instance.def, cid.promoted);
364-
match res.and_then(|body| eval_body_using_ecx(ecx, cid, body)) {
364+
match res.and_then(|body| eval_body_using_ecx(&mut ecx, cid, body)) {
365365
Err(error) => {
366366
let (error, backtrace) = error.into_parts();
367367
backtrace.print_backtrace();

compiler/rustc_const_eval/src/interpret/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ where
8484
impl<'tcx> InterpretationResult<'tcx> for mir::interpret::ConstAllocation<'tcx> {
8585
fn make_result<'mir>(
8686
mplace: MPlaceTy<'tcx>,
87-
ecx: &mut InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
87+
mut ecx: InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
8888
) -> Self {
8989
let alloc_id = mplace.ptr().provenance.unwrap().alloc_id();
9090
let alloc = ecx.memory.alloc_map.swap_remove(&alloc_id).unwrap().1;

0 commit comments

Comments
 (0)