Skip to content

Commit a0acc58

Browse files
committed
Improve print_type.
`ty::Param`s have a name, might as well print it.
1 parent f8e355c commit a0acc58

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

compiler/rustc_const_eval/src/util/type_name.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,16 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
4242
| ty::UnsafeBinder(_) => self.pretty_print_type(ty),
4343

4444
// Placeholders (all printed as `_` to uniformize them).
45-
ty::Param(_) | ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) | ty::Error(_) => {
45+
ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) | ty::Error(_) => {
4646
write!(self, "_")?;
4747
Ok(())
4848
}
4949

50+
ty::Param(param_ty) => {
51+
write!(self, "{}", param_ty.name)?;
52+
Ok(())
53+
}
54+
5055
// Types with identity (print the module path).
5156
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), args)
5257
| ty::FnDef(def_id, args)

tests/ui/issues/issue-61894.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ impl<M> Bar<M> {
1717
}
1818

1919
fn main() {
20-
assert_eq!(Bar(()).foo(), "issue_61894::Bar<_>::foo::f");
20+
assert_eq!(Bar(()).foo(), "issue_61894::Bar<M>::foo::f");
2121
}

0 commit comments

Comments
 (0)