Rollup merge of #152991 - RalfJung:interpret-step-trace, r=Kivooeo

fix interpreter tracing output

https://github.com/rust-lang/rust/pull/144708 accidentally changed the output of `MIRI_LOG=info <miri run>` in two ways:
- by adding `stmt=`/`terminator=` prefixes
- by changing the statement printing to be a verbose debug version instead of MIR pretty-printing

This fixes both of these:
- use explicit format strings to avoid the prefixes
- fix inconsistency in Debug impls for MIR types: now both TerminatorKind and StatementKind are pretty-printed, and Terminator and Statement just forward to the *Kind output
This commit is contained in:
Jonathan Brouwer
2026-02-23 20:46:14 +01:00
committed by GitHub
4 changed files with 16 additions and 6 deletions
@@ -86,7 +86,7 @@ pub fn eval_statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'t
span = ?stmt.source_info.span,
tracing_separate_thread = Empty,
)
.or_if_tracing_disabled(|| info!(stmt = ?stmt.kind));
.or_if_tracing_disabled(|| info!("{:?}", stmt.kind));
use rustc_middle::mir::StatementKind::*;
@@ -490,7 +490,7 @@ fn eval_terminator(&mut self, terminator: &mir::Terminator<'tcx>) -> InterpResul
span = ?terminator.source_info.span,
tracing_separate_thread = Empty,
)
.or_if_tracing_disabled(|| info!(terminator = ?terminator.kind));
.or_if_tracing_disabled(|| info!("{:?}", terminator.kind));
use rustc_middle::mir::TerminatorKind::*;
match terminator.kind {
+12 -2
View File
@@ -802,10 +802,10 @@ fn write_basic_block(
}
}
impl Debug for Statement<'_> {
impl Debug for StatementKind<'_> {
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
use self::StatementKind::*;
match self.kind {
match *self {
Assign(box (ref place, ref rv)) => write!(fmt, "{place:?} = {rv:?}"),
FakeRead(box (ref cause, ref place)) => {
write!(fmt, "FakeRead({cause:?}, {place:?})")
@@ -844,6 +844,11 @@ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
}
}
}
impl Debug for Statement<'_> {
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
self.kind.fmt(fmt)
}
}
impl Debug for StmtDebugInfo<'_> {
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
@@ -915,6 +920,11 @@ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
}
}
}
impl Debug for Terminator<'_> {
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
self.kind.fmt(fmt)
}
}
impl<'tcx> TerminatorKind<'tcx> {
/// Writes the "head" part of the terminator; that is, its name and the data it uses to pick the
+1 -1
View File
@@ -306,7 +306,7 @@ pub enum FakeBorrowKind {
/// Not all of these are allowed at every [`MirPhase`]. Check the documentation there to see which
/// ones you do not have to worry about. The MIR validator will generally enforce such restrictions,
/// causing an ICE if they are violated.
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)]
#[derive(Clone, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub enum StatementKind<'tcx> {
/// Assign statements roughly correspond to an assignment in Rust proper (`x = ...`) except
+1 -1
View File
@@ -444,7 +444,7 @@ macro_rules! add {
}
}
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
#[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub struct Terminator<'tcx> {
pub source_info: SourceInfo,
pub kind: TerminatorKind<'tcx>,