about summary refs log tree commit diff
path: root/clippy_lints/src/methods
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-04-07 04:36:31 +0000
committerbors <bors@rust-lang.org>2021-04-07 04:36:31 +0000
commitdb6ea84f8790e9e8488ee917ab72af28a4eccf61 (patch)
tree3fb5e01254bb74e30627dfca8370999204974bc0 /clippy_lints/src/methods
parent624e8aad325925b43ee5a1fe1774055fdbd82397 (diff)
parent47f0c15f67e334338b82deef1e812f157a54dcf2 (diff)
Auto merge of #7046 - camsteffen:symbol-optimize, r=giraffate
Some symbol optimizations

changelog: none
Diffstat (limited to 'clippy_lints/src/methods')
-rw-r--r--clippy_lints/src/methods/or_fun_call.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/clippy_lints/src/methods/or_fun_call.rs b/clippy_lints/src/methods/or_fun_call.rs
index df89da5d3e0..800172f4cf3 100644
--- a/clippy_lints/src/methods/or_fun_call.rs
+++ b/clippy_lints/src/methods/or_fun_call.rs
@@ -10,7 +10,7 @@ use rustc_hir::{BlockCheckMode, UnsafeSource};
 use rustc_lint::LateContext;
 use rustc_middle::ty;
 use rustc_span::source_map::Span;
-use rustc_span::symbol::sym;
+use rustc_span::symbol::{kw, sym};
 use std::borrow::Cow;
 
 use super::OR_FUN_CALL;
@@ -38,8 +38,8 @@ pub(super) fn check<'tcx>(
             if !or_has_args;
             if name == "unwrap_or";
             if let hir::ExprKind::Path(ref qpath) = fun.kind;
-            let path = &*last_path_segment(qpath).ident.as_str();
-            if ["default", "new"].contains(&path);
+            let path = last_path_segment(qpath).ident.name;
+            if matches!(path, kw::Default | sym::new);
             let arg_ty = cx.typeck_results().expr_ty(arg);
             if let Some(default_trait_id) = get_trait_def_id(cx, &paths::DEFAULT_TRAIT);
             if implements_trait(cx, arg_ty, default_trait_id, &[]);