Skip to content

Commit 01392a5

Browse files
committed
Move InterpCx into eval_in_interpreter
1 parent f10430e commit 01392a5

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -282,28 +282,28 @@ 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> {
297297
fn make_result<'mir>(
298298
mplace: MPlaceTy<'tcx>,
299-
ecx: &mut InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
299+
ecx: InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
300300
) -> Self;
301301
}
302302

303303
impl<'tcx> InterpretationResult<'tcx> for ConstAlloc<'tcx> {
304304
fn make_result<'mir>(
305305
mplace: MPlaceTy<'tcx>,
306-
_ecx: &mut InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
306+
_ecx: InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
307307
) -> Self {
308308
ConstAlloc { alloc_id: mplace.ptr().provenance.unwrap().alloc_id(), ty: mplace.layout.ty }
309309
}
@@ -336,7 +336,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
336336
let def = cid.instance.def.def_id();
337337
let is_static = tcx.is_static(def);
338338

339-
let mut ecx = InterpCx::new(
339+
let ecx = InterpCx::new(
340340
tcx,
341341
tcx.def_span(def),
342342
key.param_env,
@@ -346,19 +346,19 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
346346
// so we have to reject reading mutable global memory.
347347
CompileTimeInterpreter::new(CanAccessMutGlobal::from(is_static), CheckAlignment::Error),
348348
);
349-
eval_in_interpreter(&mut ecx, cid, is_static)
349+
eval_in_interpreter(ecx, cid, is_static)
350350
}
351351

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

360360
let res = ecx.load_mir(cid.instance.def, cid.promoted);
361-
match res.and_then(|body| eval_body_using_ecx(ecx, cid, body)) {
361+
match res.and_then(|body| eval_body_using_ecx(&mut ecx, cid, body)) {
362362
Err(error) => {
363363
let (error, backtrace) = error.into_parts();
364364
backtrace.print_backtrace();

compiler/rustc_const_eval/src/interpret/util.rs

+1-1
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)