@@ -284,15 +284,22 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
284
284
let def = cid. instance . def . def_id ( ) ;
285
285
let is_static = tcx. is_static ( def) ;
286
286
287
- let mut ecx = InterpCx :: new (
287
+ let ecx = InterpCx :: new (
288
288
tcx,
289
289
tcx. def_span ( def) ,
290
290
key. param_env ,
291
291
// Statics (and promoteds inside statics) may access other statics, because unlike consts
292
292
// they do not have to behave "as if" they were evaluated at runtime.
293
293
CompileTimeInterpreter :: new ( CanAccessStatics :: from ( is_static) , CheckAlignment :: Error ) ,
294
294
) ;
295
+ eval_in_interpreter ( ecx, cid, is_static)
296
+ }
295
297
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 > {
296
303
let res = ecx. load_mir ( cid. instance . def , cid. promoted ) ;
297
304
match res. and_then ( |body| eval_body_using_ecx ( & mut ecx, cid, & body) ) {
298
305
Err ( error) => {
@@ -305,7 +312,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
305
312
// If the current item has generics, we'd like to enrich the message with the
306
313
// instance and its args: to show the actual compile-time values, in addition to
307
314
// the expression, leading to the const eval error.
308
- let instance = & key . value . instance ;
315
+ let instance = & cid . instance ;
309
316
if !instance. args . is_empty ( ) {
310
317
let instance = with_no_trimmed_paths ! ( instance. to_string( ) ) ;
311
318
( "const_with_path" , instance)
0 commit comments