Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b443c22

Browse files
committed
Split eval_to_allocation_raw_provider
1 parent ad6e250 commit b443c22

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,22 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
284284
let def = cid.instance.def.def_id();
285285
let is_static = tcx.is_static(def);
286286

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

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

0 commit comments

Comments
 (0)