@@ -19,7 +19,7 @@ use rustc_middle::ty::visit::TypeVisitableExt;
19
19
use rustc_middle:: ty:: { self , IsSuggestable , Ty , TyCtxt } ;
20
20
use rustc_middle:: { bug, span_bug} ;
21
21
use rustc_session:: Session ;
22
- use rustc_span:: { DUMMY_SP , Ident , Span , Symbol , kw, sym} ;
22
+ use rustc_span:: { DUMMY_SP , Ident , Span , kw, sym} ;
23
23
use rustc_trait_selection:: error_reporting:: infer:: { FailureCode , ObligationCauseExt } ;
24
24
use rustc_trait_selection:: infer:: InferCtxtExt ;
25
25
use rustc_trait_selection:: traits:: { self , ObligationCauseCode , ObligationCtxt , SelectionContext } ;
@@ -2720,21 +2720,18 @@ impl FnParam<'_> {
2720
2720
}
2721
2721
}
2722
2722
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
-
2733
2723
fn display ( & self , idx : usize ) -> impl ' _ + fmt:: Display {
2734
2724
struct D < ' a > ( FnParam < ' a > , usize ) ;
2735
2725
impl fmt:: Display for D < ' _ > {
2736
2726
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 {
2738
2735
write ! ( f, "`{name}`" )
2739
2736
} else {
2740
2737
write ! ( f, "parameter #{}" , self . 1 + 1 )
0 commit comments