mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-10 19:16:51 +00:00
Step limit is now terminator limit
This commit is contained in:
parent
b63c6bbfee
commit
0ca4b45a0c
@ -196,7 +196,7 @@ impl<'tcx> Error for EvalError<'tcx> {
|
||||
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 =>
|
||||
|
@ -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,
|
||||
|
@ -19,7 +19,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
|
||||
/// 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 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
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)?;
|
||||
|
Loading…
Reference in New Issue
Block a user