Skip to content

Commit

Permalink
Rollup merge of rust-lang#66726 - CAD97:miri-recursion-limit, r=RalfJung
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Centril committed Dec 1, 2019
2 parents 99f9fa3 + 52426ab commit 60f4212
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
4 changes: 0 additions & 4 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ pub struct Session {
/// The maximum length of types during monomorphization.
pub type_length_limit: Once<usize>,

/// The maximum number of stackframes allowed in const eval.
pub const_eval_stack_frame_limit: usize,

/// Map from imported macro spans (which consist of
/// the localized span for the macro body) to the
/// macro name and definition span in the source crate.
Expand Down Expand Up @@ -1158,7 +1155,6 @@ fn build_session_(
features: Once::new(),
recursion_limit: Once::new(),
type_length_limit: Once::new(),
const_eval_stack_frame_limit: 100,
imported_macro_spans: OneThread::new(RefCell::new(FxHashMap::default())),
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
cgu_reuse_tracker,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {

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

if self.stack.len() > self.tcx.sess.const_eval_stack_frame_limit {
if self.stack.len() > *self.tcx.sess.recursion_limit.get() {
throw_exhaust!(StackFrameLimitReached)
} else {
Ok(())
Expand Down

0 comments on commit 60f4212

Please sign in to comment.