Skip to content

Commit 16032c5

Browse files
committed
Auto merge of rust-lang#8310 - camelid:rm-stringification, r=Manishearth
Remove unnecessary `Symbol` stringification This should (slightly) improve performance and enhance code quality. changelog: none
2 parents fff8e78 + d9f401a commit 16032c5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

clippy_lints/src/matches.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use rustc_middle::ty::{self, Ty, TyS, VariantDef};
3030
use rustc_semver::RustcVersion;
3131
use rustc_session::{declare_tool_lint, impl_lint_pass};
3232
use rustc_span::source_map::{Span, Spanned};
33-
use rustc_span::sym;
33+
use rustc_span::{sym, symbol::kw};
3434
use std::cmp::Ordering;
3535
use 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

Comments
 (0)