Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 172662d

Browse files
committed
Add back Machine::before_terminator(...) method
Added it back because it's used by Miri, but in the compiler itself, it will not do anything (just return `Ok(())`.
1 parent 08de246 commit 172662d

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

compiler/rustc_const_eval/src/const_eval/machine.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,11 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
561561
throw_unsup_format!("pointer arithmetic or comparison is not supported at compile-time");
562562
}
563563

564+
// Not used here, but used by Miri (see `src/tools/miri/src/machine.rs`).
565+
fn before_terminator(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
566+
Ok(())
567+
}
568+
564569
fn increment_const_eval_counter(ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
565570
// The step limit has already been hit in a previous call to `increment_const_eval_counter`.
566571
if ecx.machine.steps_remaining == 0 {

compiler/rustc_const_eval/src/interpret/machine.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,12 @@ pub trait Machine<'mir, 'tcx>: Sized {
243243
ecx.stack_mut()[frame].locals[local].access_mut()
244244
}
245245

246+
/// Called before a basic block terminator is executed.
247+
#[inline]
248+
fn before_terminator(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
249+
Ok(())
250+
}
251+
246252
/// Called when the interpreter encounters a `StatementKind::ConstEvalCounter` instruction.
247253
/// You can use this to detect long or endlessly running programs.
248254
#[inline]

compiler/rustc_const_eval/src/interpret/step.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
6262
return Ok(true);
6363
}
6464

65+
M::before_terminator(self)?;
66+
6567
let terminator = basic_block.terminator();
6668
self.terminator(terminator)?;
6769
Ok(true)

0 commit comments

Comments
 (0)