@@ -2,6 +2,7 @@ use std::mem;
2
2
3
3
use either:: { Left , Right } ;
4
4
5
+ use rustc_data_structures:: stack:: ensure_sufficient_stack;
5
6
use rustc_hir:: def:: DefKind ;
6
7
use rustc_middle:: mir:: interpret:: { AllocId , ErrorHandled , InterpErrorInfo } ;
7
8
use rustc_middle:: mir:: pretty:: write_allocation_bytes;
@@ -305,10 +306,13 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
305
306
// they do not have to behave "as if" they were evaluated at runtime.
306
307
CompileTimeInterpreter :: new ( CanAccessStatics :: from ( is_static) , CheckAlignment :: Error ) ,
307
308
) ;
308
- eval_in_interpreter ( ecx, cid, is_static)
309
+ // Evaluating this MIR in the interpreter may in turn require evaluating constants to
310
+ // allocations. As the recursion depends on what the user wrote, we need to protect ourselves
311
+ // from stack overflow.
312
+ ensure_sufficient_stack ( || eval_in_interpreter ( ecx, cid, is_static) )
309
313
}
310
314
311
- pub fn eval_in_interpreter < ' mir , ' tcx > (
315
+ fn eval_in_interpreter < ' mir , ' tcx > (
312
316
mut ecx : InterpCx < ' mir , ' tcx , CompileTimeInterpreter < ' mir , ' tcx > > ,
313
317
cid : GlobalId < ' tcx > ,
314
318
is_static : bool ,
0 commit comments