Skip to content

Commit 0ca4b45

Browse files
committed
Step limit is now terminator limit
1 parent b63c6bb commit 0ca4b45

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/librustc/mir/interpret/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl<'tcx> Error for EvalError<'tcx> {
196196
OutOfMemory{..} =>
197197
"could not allocate more memory",
198198
ExecutionTimeLimitReached =>
199-
"reached the configured maximum execution time",
199+
"the expression was too complex to be evaluated or resulted in an infinite loop",
200200
StackFrameLimitReached =>
201201
"reached the configured maximum number of stack frames",
202202
OutOfTls =>

src/librustc_mir/interpret/eval_context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub struct EvalContext<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> {
4141
/// The maximum number of stack frames allowed
4242
pub(crate) stack_limit: usize,
4343

44-
/// The maximum number of operations that may be executed.
44+
/// The maximum number of terminators that may be evaluated.
4545
/// This prevents infinite loops and huge computations from freezing up const eval.
4646
/// Remove once halting problem is solved.
4747
pub(crate) steps_remaining: usize,

src/librustc_mir/interpret/step.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
1919

2020
/// Returns true as long as there are more things to do.
2121
pub fn step(&mut self) -> EvalResult<'tcx, bool> {
22-
self.inc_step_counter_and_check_limit(1)?;
2322
if self.stack.is_empty() {
2423
return Ok(false);
2524
}
@@ -37,6 +36,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
3736
return Ok(true);
3837
}
3938

39+
self.inc_step_counter_and_check_limit(1)?;
40+
4041
let terminator = basic_block.terminator();
4142
assert_eq!(old_frames, self.cur_frame());
4243
self.terminator(terminator)?;

0 commit comments

Comments
 (0)