]> git.lizzy.rs Git - rust.git/commitdiff
Step limit is now terminator limit
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 19 Feb 2018 11:00:15 +0000 (12:00 +0100)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Thu, 8 Mar 2018 07:34:17 +0000 (08:34 +0100)
src/librustc/mir/interpret/error.rs
src/librustc_mir/interpret/eval_context.rs
src/librustc_mir/interpret/step.rs

index bb27628fa9c73f4dab295ecd80dc3e1d4ed16414..d6df340e2f68fbb9b76b36e57939b5dda0ff5584 100644 (file)
@@ -196,7 +196,7 @@ fn description(&self) -> &str {
             OutOfMemory{..} =>
                 "could not allocate more memory",
             ExecutionTimeLimitReached =>
-                "reached the configured maximum execution time",
+                "the expression was too complex to be evaluated or resulted in an infinite loop",
             StackFrameLimitReached =>
                 "reached the configured maximum number of stack frames",
             OutOfTls =>
index f46d5631060837155cdc67f9a05210065989e9cd..64e823564671b22762f49ae84ff9a32b9a9d1ec3 100644 (file)
@@ -41,7 +41,7 @@ pub struct EvalContext<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> {
     /// The maximum number of stack frames allowed
     pub(crate) stack_limit: usize,
 
-    /// The maximum number of operations that may be executed.
+    /// The maximum number of terminators that may be evaluated.
     /// This prevents infinite loops and huge computations from freezing up const eval.
     /// Remove once halting problem is solved.
     pub(crate) steps_remaining: usize,
index 54fd364d3f820452b3d91f9ae77a7e46ffbaa551..4e1750caf26ba30f637e2c3196fb210d0274dce2 100644 (file)
@@ -19,7 +19,6 @@ pub fn inc_step_counter_and_check_limit(&mut self, n: usize) -> EvalResult<'tcx>
 
     /// Returns true as long as there are more things to do.
     pub fn step(&mut self) -> EvalResult<'tcx, bool> {
-        self.inc_step_counter_and_check_limit(1)?;
         if self.stack.is_empty() {
             return Ok(false);
         }
@@ -37,6 +36,8 @@ pub fn step(&mut self) -> EvalResult<'tcx, bool> {
             return Ok(true);
         }
 
+        self.inc_step_counter_and_check_limit(1)?;
+
         let terminator = basic_block.terminator();
         assert_eq!(old_frames, self.cur_frame());
         self.terminator(terminator)?;