Also debug
This commit is contained in:
parent
1e5ec0a12c
commit
f368527802
@ -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))
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
pub trait IrPrint<T> {
|
||||
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 {
|
||||
<I as IrPrint<$ty<I>>>::print(self, fmt)
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: Interner> fmt::Debug for $ty<I> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
<I as IrPrint<$ty<I>>>::print_debug(self, fmt)
|
||||
}
|
||||
}
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
@ -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<I: Interner> fmt::Debug for TraitRef<I> {
|
||||
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<I: Interner, U: Interner> Lift<U> for TraitRef<I>
|
||||
where
|
||||
|
Loading…
Reference in New Issue
Block a user