Also debug

This commit is contained in:
Michael Goulet 2024-05-10 15:11:09 -04:00
parent 1e5ec0a12c
commit f368527802
3 changed files with 11 additions and 21 deletions

View File

@ -350,4 +350,8 @@ fn print(t: &T, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Ok(()) Ok(())
}) })
} }
fn print_debug(t: &T, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
with_no_trimmed_paths!(Self::print(t, fmt))
}
} }

View File

@ -4,6 +4,7 @@
pub trait IrPrint<T> { pub trait IrPrint<T> {
fn print(t: &T, fmt: &mut fmt::Formatter<'_>) -> fmt::Result; 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 { 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) <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)
}
}
)* )*
} }
} }

View File

@ -1,5 +1,3 @@
use std::fmt;
use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable}; use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};
use crate::fold::{FallibleTypeFolder, TypeFoldable}; 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. // FIXME(compiler-errors): Make this into a `Lift_Generic` impl.
impl<I: Interner, U: Interner> Lift<U> for TraitRef<I> impl<I: Interner, U: Interner> Lift<U> for TraitRef<I>
where where