Skip to content

Commit 8472621

Browse files
authored
Rollup merge of #152991 - RalfJung:interpret-step-trace, r=Kivooeo
fix interpreter tracing output #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
2 parents ef8d529 + 5b87b99 commit 8472621

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

compiler/rustc_const_eval/src/interpret/step.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
8686
span = ?stmt.source_info.span,
8787
tracing_separate_thread = Empty,
8888
)
89-
.or_if_tracing_disabled(|| info!(stmt = ?stmt.kind));
89+
.or_if_tracing_disabled(|| info!("{:?}", stmt.kind));
9090

9191
use rustc_middle::mir::StatementKind::*;
9292

@@ -490,7 +490,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
490490
span = ?terminator.source_info.span,
491491
tracing_separate_thread = Empty,
492492
)
493-
.or_if_tracing_disabled(|| info!(terminator = ?terminator.kind));
493+
.or_if_tracing_disabled(|| info!("{:?}", terminator.kind));
494494

495495
use rustc_middle::mir::TerminatorKind::*;
496496
match terminator.kind {

compiler/rustc_middle/src/mir/pretty.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,10 +802,10 @@ impl<'de, 'tcx> MirWriter<'de, 'tcx> {
802802
}
803803
}
804804

805-
impl Debug for Statement<'_> {
805+
impl Debug for StatementKind<'_> {
806806
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
807807
use self::StatementKind::*;
808-
match self.kind {
808+
match *self {
809809
Assign(box (ref place, ref rv)) => write!(fmt, "{place:?} = {rv:?}"),
810810
FakeRead(box (ref cause, ref place)) => {
811811
write!(fmt, "FakeRead({cause:?}, {place:?})")
@@ -844,6 +844,11 @@ impl Debug for Statement<'_> {
844844
}
845845
}
846846
}
847+
impl Debug for Statement<'_> {
848+
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
849+
self.kind.fmt(fmt)
850+
}
851+
}
847852

848853
impl Debug for StmtDebugInfo<'_> {
849854
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
@@ -915,6 +920,11 @@ impl<'tcx> Debug for TerminatorKind<'tcx> {
915920
}
916921
}
917922
}
923+
impl Debug for Terminator<'_> {
924+
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
925+
self.kind.fmt(fmt)
926+
}
927+
}
918928

919929
impl<'tcx> TerminatorKind<'tcx> {
920930
/// Writes the "head" part of the terminator; that is, its name and the data it uses to pick the

compiler/rustc_middle/src/mir/syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ pub enum FakeBorrowKind {
306306
/// Not all of these are allowed at every [`MirPhase`]. Check the documentation there to see which
307307
/// ones you do not have to worry about. The MIR validator will generally enforce such restrictions,
308308
/// causing an ICE if they are violated.
309-
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)]
309+
#[derive(Clone, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)]
310310
#[derive(TypeFoldable, TypeVisitable)]
311311
pub enum StatementKind<'tcx> {
312312
/// Assign statements roughly correspond to an assignment in Rust proper (`x = ...`) except

compiler/rustc_middle/src/mir/terminator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ impl<O> AssertKind<O> {
444444
}
445445
}
446446

447-
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
447+
#[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
448448
pub struct Terminator<'tcx> {
449449
pub source_info: SourceInfo,
450450
pub kind: TerminatorKind<'tcx>,

0 commit comments

Comments
 (0)