@@ -30,7 +30,7 @@ use rustc_middle::ty::{self, Ty, TyS, VariantDef};
30
30
use rustc_semver:: RustcVersion ;
31
31
use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
32
32
use rustc_span:: source_map:: { Span , Spanned } ;
33
- use rustc_span:: sym;
33
+ use rustc_span:: { sym, symbol :: kw } ;
34
34
use std:: cmp:: Ordering ;
35
35
use std:: collections:: hash_map:: Entry ;
36
36
@@ -961,13 +961,13 @@ fn check_wild_err_arm<'tcx>(cx: &LateContext<'tcx>, ex: &Expr<'tcx>, arms: &[Arm
961
961
let path_str = rustc_hir_pretty:: to_string ( rustc_hir_pretty:: NO_ANN , |s| s. print_qpath ( path, false ) ) ;
962
962
if path_str == "Err" {
963
963
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 ;
965
965
if !matching_wild {
966
966
// Looking for unused bindings (i.e.: `_e`)
967
967
for pat in inner. iter ( ) {
968
968
if let PatKind :: Binding ( _, id, ident, None ) = pat. kind {
969
969
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 ;
971
971
matching_wild = true ;
972
972
}
973
973
}
@@ -982,7 +982,7 @@ fn check_wild_err_arm<'tcx>(cx: &LateContext<'tcx>, ex: &Expr<'tcx>, arms: &[Arm
982
982
span_lint_and_note( cx,
983
983
MATCH_WILD_ERR_ARM ,
984
984
arm. pat. span,
985
- & format!( "`Err({})` matches all errors" , & ident_bind_name) ,
985
+ & format!( "`Err({})` matches all errors" , ident_bind_name) ,
986
986
None ,
987
987
"match each error separately or use the error output, or use `.except(msg)` if the error case is unreachable" ,
988
988
) ;
0 commit comments