1
Fork 0

Always format to internal String in FmtPrinter

This avoids monomorphizing for different parameters, decreasing generic code
instantiated downstream from rustc_middle.
This commit is contained in:
Mark Rousskov 2022-02-18 16:15:29 -05:00
parent 45e2c2881d
commit efb99d780d
10 changed files with 82 additions and 80 deletions

View file

@ -22,10 +22,13 @@ use std::sync::Arc;
impl fmt::Debug for ty::TraitDef {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
ty::tls::with(|tcx| {
with_no_trimmed_paths!(
FmtPrinter::new(tcx, f, Namespace::TypeNS).print_def_path(self.def_id, &[])?
);
Ok(())
with_no_trimmed_paths!({
f.write_str(
&FmtPrinter::new(tcx, Namespace::TypeNS)
.print_def_path(self.def_id, &[])?
.into_buffer(),
)
})
})
}
}
@ -33,10 +36,13 @@ impl fmt::Debug for ty::TraitDef {
impl fmt::Debug for ty::AdtDef {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
ty::tls::with(|tcx| {
with_no_trimmed_paths!(
FmtPrinter::new(tcx, f, Namespace::TypeNS).print_def_path(self.did, &[])?
);
Ok(())
with_no_trimmed_paths!({
f.write_str(
&FmtPrinter::new(tcx, Namespace::TypeNS)
.print_def_path(self.did, &[])?
.into_buffer(),
)
})
})
}
}