Skip to content

Commit f368527

Browse files
Also debug
1 parent 1e5ec0a commit f368527

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

compiler/rustc_middle/src/ty/print/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -350,4 +350,8 @@ where
350350
Ok(())
351351
})
352352
}
353+
354+
fn print_debug(t: &T, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
355+
with_no_trimmed_paths!(Self::print(t, fmt))
356+
}
353357
}

compiler/rustc_type_ir/src/ir_print.rs

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::{Interner, TraitRef};
44

55
pub trait IrPrint<T> {
66
fn print(t: &T, fmt: &mut fmt::Formatter<'_>) -> fmt::Result;
7+
fn print_debug(t: &T, fmt: &mut fmt::Formatter<'_>) -> fmt::Result;
78
}
89

910
macro_rules! define_display_via_print {
@@ -14,6 +15,12 @@ macro_rules! define_display_via_print {
1415
<I as IrPrint<$ty<I>>>::print(self, fmt)
1516
}
1617
}
18+
19+
impl<I: Interner> fmt::Debug for $ty<I> {
20+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
21+
<I as IrPrint<$ty<I>>>::print_debug(self, fmt)
22+
}
23+
}
1724
)*
1825
}
1926
}

compiler/rustc_type_ir/src/trait_ref.rs

-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::fmt;
2-
31
use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};
42

53
use crate::fold::{FallibleTypeFolder, TypeFoldable};
@@ -71,25 +69,6 @@ impl<I: Interner> TraitRef<I> {
7169
}
7270
}
7371

74-
impl<I: Interner> fmt::Debug for TraitRef<I> {
75-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
76-
let TraitRef { def_id, args, _use_trait_ref_new_instead: () } = self;
77-
let mut args = args.into_iter().peekable();
78-
write!(f, "{def_id:?}")?;
79-
if args.peek().is_some() {
80-
write!(f, "<")?;
81-
for (i, arg) in args.enumerate() {
82-
if i > 0 {
83-
write!(f, ", ")?;
84-
}
85-
write!(f, "{arg:#?}")?;
86-
}
87-
write!(f, ">")?;
88-
}
89-
Ok(())
90-
}
91-
}
92-
9372
// FIXME(compiler-errors): Make this into a `Lift_Generic` impl.
9473
impl<I: Interner, U: Interner> Lift<U> for TraitRef<I>
9574
where

0 commit comments

Comments
 (0)