Skip to content

Commit 60f4212

Browse files
authored
Rollup merge of rust-lang#66726 - CAD97:miri-recursion-limit, r=RalfJung
Use recursion_limit for const eval stack limit cc rust-lang/miri#643 @orium @RalfJung I'm really not certain how exactly to handle this change, but it looks like it's that simple. Reuse `recursion_limit` ("The maximum recursion limit for potentially infinitely recursive operations such as auto-dereference and monomorphization") which is configurable by the user for the const evaluation stack frame limit. The other option is to make `const_eval_stack_frame_limit` configurable in the same way as `recursion_limit` (but I'm not sure how to do that and it'd be a bigger change). Fixes rust-lang/miri#643.
2 parents 99f9fa3 + 52426ab commit 60f4212

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

src/librustc/session/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ pub struct Session {
9494
/// The maximum length of types during monomorphization.
9595
pub type_length_limit: Once<usize>,
9696

97-
/// The maximum number of stackframes allowed in const eval.
98-
pub const_eval_stack_frame_limit: usize,
99-
10097
/// Map from imported macro spans (which consist of
10198
/// the localized span for the macro body) to the
10299
/// macro name and definition span in the source crate.
@@ -1158,7 +1155,6 @@ fn build_session_(
11581155
features: Once::new(),
11591156
recursion_limit: Once::new(),
11601157
type_length_limit: Once::new(),
1161-
const_eval_stack_frame_limit: 100,
11621158
imported_macro_spans: OneThread::new(RefCell::new(FxHashMap::default())),
11631159
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
11641160
cgu_reuse_tracker,

src/librustc_mir/interpret/eval_context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
548548

549549
info!("ENTERING({}) {}", self.cur_frame(), self.frame().instance);
550550

551-
if self.stack.len() > self.tcx.sess.const_eval_stack_frame_limit {
551+
if self.stack.len() > *self.tcx.sess.recursion_limit.get() {
552552
throw_exhaust!(StackFrameLimitReached)
553553
} else {
554554
Ok(())

0 commit comments

Comments
 (0)