@@ -19,7 +19,7 @@ use rustc_middle::ty::visit::TypeVisitableExt;
1919use rustc_middle:: ty:: { self , IsSuggestable , Ty , TyCtxt } ;
2020use rustc_middle:: { bug, span_bug} ;
2121use rustc_session:: Session ;
22- use rustc_span:: { DUMMY_SP , Ident , Span , Symbol , kw, sym} ;
22+ use rustc_span:: { DUMMY_SP , Ident , Span , kw, sym} ;
2323use rustc_trait_selection:: error_reporting:: infer:: { FailureCode , ObligationCauseExt } ;
2424use rustc_trait_selection:: infer:: InferCtxtExt ;
2525use rustc_trait_selection:: traits:: { self , ObligationCauseCode , ObligationCtxt , SelectionContext } ;
@@ -2720,21 +2720,18 @@ impl FnParam<'_> {
27202720 }
27212721 }
27222722
2723- fn name ( & self ) -> Option < Symbol > {
2724- match self {
2725- Self :: Param ( x) if let hir:: PatKind :: Binding ( _, _, ident, _) = x. pat . kind => {
2726- Some ( ident. name )
2727- }
2728- Self :: Name ( x) if x. name != kw:: Empty => Some ( x. name ) ,
2729- _ => None ,
2730- }
2731- }
2732-
27332723 fn display ( & self , idx : usize ) -> impl ' _ + fmt:: Display {
27342724 struct D < ' a > ( FnParam < ' a > , usize ) ;
27352725 impl fmt:: Display for D < ' _ > {
27362726 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
2737- if let Some ( name) = self . 0 . name ( ) {
2727+ let name = match self . 0 {
2728+ FnParam :: Param ( x) if let hir:: PatKind :: Binding ( _, _, ident, _) = x. pat . kind => {
2729+ Some ( ident. name )
2730+ }
2731+ FnParam :: Name ( x) if x. name != kw:: Empty => Some ( x. name ) ,
2732+ _ => None ,
2733+ } ;
2734+ if let Some ( name) = name {
27382735 write ! ( f, "`{name}`" )
27392736 } else {
27402737 write ! ( f, "parameter #{}" , self . 1 + 1 )
0 commit comments