Skip to content

Commit 7d574f7

Browse files
committed
don't execute the first statement of a constant/static/promoted right away
This might create confusion, because attempting to execute a statement can cause arbitrary stackframes to be added for the constants/statics/promoteds required by that statement. Before this commit, the first statement of the last added stackframe was executed immediately. Thus there was no way to inspect the state before that first statement.
1 parent f28feed commit 7d574f7

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/interpreter/step.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
3939
}.visit_statement(block, stmt);
4040
if current_stack == self.stack.len() {
4141
self.statement(stmt)?;
42-
} else {
43-
// ConstantExtractor added some new frames for statics/constants/promoteds
44-
// self.step() can't be "done", so it can't return false
45-
assert!(self.step()?);
4642
}
43+
// if ConstantExtractor added new frames, we don't execute anything here
44+
// but await the next call to step
4745
return Ok(true);
4846
}
4947

@@ -58,11 +56,9 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
5856
}.visit_terminator(block, terminator);
5957
if current_stack == self.stack.len() {
6058
self.terminator(terminator)?;
61-
} else {
62-
// ConstantExtractor added some new frames for statics/constants/promoteds
63-
// self.step() can't be "done", so it can't return false
64-
assert!(self.step()?);
6559
}
60+
// if ConstantExtractor added new frames, we don't execute anything here
61+
// but await the next call to step
6662
Ok(true)
6763
}
6864

0 commit comments

Comments
 (0)