Skip to content

Commit fec0b54

Browse files
committed
Split eval_to_allocation_raw_provider
1 parent f85b139 commit fec0b54

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,22 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
285285
let def = cid.instance.def.def_id();
286286
let is_static = tcx.is_static(def);
287287

288-
let mut ecx = InterpCx::new(
288+
let ecx = InterpCx::new(
289289
tcx,
290290
tcx.def_span(def),
291291
key.param_env,
292292
// Statics (and promoteds inside statics) may access other statics, because unlike consts
293293
// they do not have to behave "as if" they were evaluated at runtime.
294294
CompileTimeInterpreter::new(CanAccessStatics::from(is_static), CheckAlignment::Error),
295295
);
296+
eval_in_interpreter(ecx, cid, is_static)
297+
}
296298

299+
pub fn eval_in_interpreter<'mir, 'tcx>(
300+
mut ecx: InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
301+
cid: GlobalId<'tcx>,
302+
is_static: bool,
303+
) -> ::rustc_middle::mir::interpret::EvalToAllocationRawResult<'tcx> {
297304
let res = ecx.load_mir(cid.instance.def, cid.promoted);
298305
match res.and_then(|body| eval_body_using_ecx(&mut ecx, cid, &body)) {
299306
Err(error) => {
@@ -306,7 +313,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
306313
// If the current item has generics, we'd like to enrich the message with the
307314
// instance and its args: to show the actual compile-time values, in addition to
308315
// the expression, leading to the const eval error.
309-
let instance = &key.value.instance;
316+
let instance = &cid.instance;
310317
if !instance.args.is_empty() {
311318
let instance = with_no_trimmed_paths!(instance.to_string());
312319
("const_with_path", instance)

0 commit comments

Comments
 (0)