@@ -30,7 +30,7 @@ use rustc_middle::ty::{self, Ty, TyS, VariantDef};
3030use rustc_semver:: RustcVersion ;
3131use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
3232use rustc_span:: source_map:: { Span , Spanned } ;
33- use rustc_span:: sym;
33+ use rustc_span:: { sym, symbol :: kw } ;
3434use std:: cmp:: Ordering ;
3535use std:: collections:: hash_map:: Entry ;
3636
@@ -961,13 +961,13 @@ fn check_wild_err_arm<'tcx>(cx: &LateContext<'tcx>, ex: &Expr<'tcx>, arms: &[Arm
961961 let path_str = rustc_hir_pretty:: to_string ( rustc_hir_pretty:: NO_ANN , |s| s. print_qpath ( path, false ) ) ;
962962 if path_str == "Err" {
963963 let mut matching_wild = inner. iter ( ) . any ( is_wild) ;
964- let mut ident_bind_name = String :: from ( "_" ) ;
964+ let mut ident_bind_name = kw :: Underscore ;
965965 if !matching_wild {
966966 // Looking for unused bindings (i.e.: `_e`)
967967 for pat in inner. iter ( ) {
968968 if let PatKind :: Binding ( _, id, ident, None ) = pat. kind {
969969 if ident. as_str ( ) . starts_with ( '_' ) && !is_local_used ( cx, arm. body , id) {
970- ident_bind_name = ident. name . as_str ( ) . to_string ( ) ;
970+ ident_bind_name = ident. name ;
971971 matching_wild = true ;
972972 }
973973 }
@@ -982,7 +982,7 @@ fn check_wild_err_arm<'tcx>(cx: &LateContext<'tcx>, ex: &Expr<'tcx>, arms: &[Arm
982982 span_lint_and_note( cx,
983983 MATCH_WILD_ERR_ARM ,
984984 arm. pat. span,
985- & format!( "`Err({})` matches all errors" , & ident_bind_name) ,
985+ & format!( "`Err({})` matches all errors" , ident_bind_name) ,
986986 None ,
987987 "match each error separately or use the error output, or use `.except(msg)` if the error case is unreachable" ,
988988 ) ;
0 commit comments