about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-07-24 22:22:18 +0200
committerGitHub <noreply@github.com>2024-07-24 22:22:18 +0200
commit104a421a46f9756a3ebc1a77c40878479e99993e (patch)
tree38c04373732f4c8b8ae17e2c53962e5a72db49f4
parentd146ecdcb91f81b1fae2a1a032093af6320d08db (diff)
parent4d5ac84285e13a05c0ade4b83aeb309a1f351610 (diff)
Rollup merge of #128140 - veera-sivarajan:remove-ident-to-str-conversions, r=compiler-errors
Remove Unnecessary `.as_str()` Conversions

Because comparing interned values is much more efficient than converting a `rustc_span::symbol::Ident` to `&str`  and then doing the comparison.

docs: https://doc.rust-lang.org/stable/nightly-rustc/rustc_span/symbol/struct.Ident.html#method.as_str
-rw-r--r--compiler/rustc_hir_typeck/src/method/probe.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs
index 9cb6124ab21..ae34ddeaa87 100644
--- a/compiler/rustc_hir_typeck/src/method/probe.rs
+++ b/compiler/rustc_hir_typeck/src/method/probe.rs
@@ -1846,7 +1846,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
     /// Determine if the associated item with the given DefId matches
     /// the desired name via a doc alias.
     fn matches_by_doc_alias(&self, def_id: DefId) -> bool {
-        let Some(name) = self.method_name else {
+        let Some(method) = self.method_name else {
             return false;
         };
         let Some(local_def_id) = def_id.as_local() else {
@@ -1863,7 +1863,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
                 // #[rustc_confusables("foo", "bar"))]
                 for n in confusables {
                     if let Some(lit) = n.lit()
-                        && name.as_str() == lit.symbol.as_str()
+                        && method.name == lit.symbol
                     {
                         return true;
                     }
@@ -1883,14 +1883,14 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
                     // #[doc(alias("foo", "bar"))]
                     for n in nested {
                         if let Some(lit) = n.lit()
-                            && name.as_str() == lit.symbol.as_str()
+                            && method.name == lit.symbol
                         {
                             return true;
                         }
                     }
                 } else if let Some(meta) = v.meta_item()
                     && let Some(lit) = meta.name_value_literal()
-                    && name.as_str() == lit.symbol.as_str()
+                    && method.name == lit.symbol
                 {
                     // #[doc(alias = "foo")]
                     return true;