about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-12-01 04:49:24 +0100
committerGitHub <noreply@github.com>2019-12-01 04:49:24 +0100
commit60f4212ee537c7f5efff51c694c814b5458c8aa7 (patch)
tree0aa7ab4c9c6360843bb8efe44bb1dc46376ac82e
parent99f9fa36951b25eba43e822bd5a58508d5f22d28 (diff)
parent52426ab42dffadfcaec7d1eb4afa4d63cca11593 (diff)
Rollup merge of #66726 - CAD97:miri-recursion-limit, r=RalfJung
Use recursion_limit for const eval stack limit

cc https://github.com/rust-lang/miri/issues/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 https://github.com/rust-lang/miri/issues/643.
-rw-r--r--src/librustc/session/mod.rs4
-rw-r--r--src/librustc_mir/interpret/eval_context.rs2
2 files changed, 1 insertions, 5 deletions
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs
index 87c7e5a82a3..74ba83d0ee4 100644
--- a/src/librustc/session/mod.rs
+++ b/src/librustc/session/mod.rs
@@ -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.
@@ -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,
diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs
index 626e81fa911..228e5cad4e3 100644
--- a/src/librustc_mir/interpret/eval_context.rs
+++ b/src/librustc_mir/interpret/eval_context.rs
@@ -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(())