From 5b87b994d805b902563c08590f3b71c5c7a9b3f3 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 22 Feb 2026 22:38:46 +0100 Subject: [PATCH] fix interpreter tracing output --- compiler/rustc_const_eval/src/interpret/step.rs | 4 ++-- compiler/rustc_middle/src/mir/pretty.rs | 14 ++++++++++++-- compiler/rustc_middle/src/mir/syntax.rs | 2 +- compiler/rustc_middle/src/mir/terminator.rs | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index 0dd17f109be3..126d0fc9b7a1 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -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 { diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index e5fe01781e96..487a3c9c4ea2 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -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 diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index 35f67460f51c..c3da2f039485 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -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 diff --git a/compiler/rustc_middle/src/mir/terminator.rs b/compiler/rustc_middle/src/mir/terminator.rs index 1e7729bd8d65..650c44aa41fb 100644 --- a/compiler/rustc_middle/src/mir/terminator.rs +++ b/compiler/rustc_middle/src/mir/terminator.rs @@ -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>,