From a0acc58030c8838bbb8deec5f571d672de969ed1 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 29 Jul 2025 16:16:37 +1000 Subject: [PATCH] Improve `print_type`. `ty::Param`s have a name, might as well print it. --- compiler/rustc_const_eval/src/util/type_name.rs | 7 ++++++- tests/ui/issues/issue-61894.rs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_const_eval/src/util/type_name.rs b/compiler/rustc_const_eval/src/util/type_name.rs index e8f2728a7728f..b5859337d91d6 100644 --- a/compiler/rustc_const_eval/src/util/type_name.rs +++ b/compiler/rustc_const_eval/src/util/type_name.rs @@ -42,11 +42,16 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> { | ty::UnsafeBinder(_) => self.pretty_print_type(ty), // Placeholders (all printed as `_` to uniformize them). - ty::Param(_) | ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) | ty::Error(_) => { + ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) | ty::Error(_) => { write!(self, "_")?; Ok(()) } + ty::Param(param_ty) => { + write!(self, "{}", param_ty.name)?; + Ok(()) + } + // Types with identity (print the module path). ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), args) | ty::FnDef(def_id, args) diff --git a/tests/ui/issues/issue-61894.rs b/tests/ui/issues/issue-61894.rs index 40ad6a8d76a01..75ecb8556fe98 100644 --- a/tests/ui/issues/issue-61894.rs +++ b/tests/ui/issues/issue-61894.rs @@ -17,5 +17,5 @@ impl Bar { } fn main() { - assert_eq!(Bar(()).foo(), "issue_61894::Bar<_>::foo::f"); + assert_eq!(Bar(()).foo(), "issue_61894::Bar::foo::f"); }