From f3685278020f0f05314599604c24b52a22ed6621 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 10 May 2024 15:11:09 -0400 Subject: [PATCH] Also debug --- compiler/rustc_middle/src/ty/print/mod.rs | 4 ++++ compiler/rustc_type_ir/src/ir_print.rs | 7 +++++++ compiler/rustc_type_ir/src/trait_ref.rs | 21 --------------------- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs index d0bae917073..e7589737d64 100644 --- a/compiler/rustc_middle/src/ty/print/mod.rs +++ b/compiler/rustc_middle/src/ty/print/mod.rs @@ -350,4 +350,8 @@ fn print(t: &T, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Ok(()) }) } + + fn print_debug(t: &T, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + with_no_trimmed_paths!(Self::print(t, fmt)) + } } diff --git a/compiler/rustc_type_ir/src/ir_print.rs b/compiler/rustc_type_ir/src/ir_print.rs index 89c30fcd267..265c582ac44 100644 --- a/compiler/rustc_type_ir/src/ir_print.rs +++ b/compiler/rustc_type_ir/src/ir_print.rs @@ -4,6 +4,7 @@ pub trait IrPrint { fn print(t: &T, fmt: &mut fmt::Formatter<'_>) -> fmt::Result; + fn print_debug(t: &T, fmt: &mut fmt::Formatter<'_>) -> fmt::Result; } macro_rules! define_display_via_print { @@ -14,6 +15,12 @@ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { >>::print(self, fmt) } } + + impl fmt::Debug for $ty { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + >>::print_debug(self, fmt) + } + } )* } } diff --git a/compiler/rustc_type_ir/src/trait_ref.rs b/compiler/rustc_type_ir/src/trait_ref.rs index ad1350d845d..a91fd1b2911 100644 --- a/compiler/rustc_type_ir/src/trait_ref.rs +++ b/compiler/rustc_type_ir/src/trait_ref.rs @@ -1,5 +1,3 @@ -use std::fmt; - use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable}; use crate::fold::{FallibleTypeFolder, TypeFoldable}; @@ -71,25 +69,6 @@ pub fn self_ty(&self) -> I::Ty { } } -impl fmt::Debug for TraitRef { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let TraitRef { def_id, args, _use_trait_ref_new_instead: () } = self; - let mut args = args.into_iter().peekable(); - write!(f, "{def_id:?}")?; - if args.peek().is_some() { - write!(f, "<")?; - for (i, arg) in args.enumerate() { - if i > 0 { - write!(f, ", ")?; - } - write!(f, "{arg:#?}")?; - } - write!(f, ">")?; - } - Ok(()) - } -} - // FIXME(compiler-errors): Make this into a `Lift_Generic` impl. impl Lift for TraitRef where