about summary refs log tree commit diff
path: root/src/tools/rust-analyzer
diff options
context:
space:
mode:
authorKirill Bulatov <mail4score@gmail.com>2024-12-09 22:30:28 +0200
committerKirill Bulatov <mail4score@gmail.com>2024-12-09 22:38:55 +0200
commit160cb324c173ebab94d27a34b2372941233251be (patch)
tree0468b96763ace06fdb7e6ce3eabace246b594488 /src/tools/rust-analyzer
parent78ea49e4e7f224e1c0d4b6292a7bf49595ab666d (diff)
downloadrust-160cb324c173ebab94d27a34b2372941233251be.tar.gz
rust-160cb324c173ebab94d27a34b2372941233251be.zip
Unite more bool hashing
Diffstat (limited to 'src/tools/rust-analyzer')
-rw-r--r--src/tools/rust-analyzer/crates/rust-analyzer/Cargo.toml14
-rw-r--r--src/tools/rust-analyzer/crates/rust-analyzer/src/lib.rs17
2 files changed, 16 insertions, 15 deletions
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/Cargo.toml b/src/tools/rust-analyzer/crates/rust-analyzer/Cargo.toml
index 022b0a0ecf1..58d871270d9 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/Cargo.toml
+++ b/src/tools/rust-analyzer/crates/rust-analyzer/Cargo.toml
@@ -92,13 +92,13 @@ jemalloc = ["jemallocator", "profile/jemalloc"]
 force-always-assert = ["always-assert/force"]
 sysroot-abi = []
 in-rust-tree = [
-    "sysroot-abi",
-    "syntax/in-rust-tree",
-    "parser/in-rust-tree",
-    "hir/in-rust-tree",
-    "hir-def/in-rust-tree",
-    "hir-ty/in-rust-tree",
-    "load-cargo/in-rust-tree",
+  "sysroot-abi",
+  "syntax/in-rust-tree",
+  "parser/in-rust-tree",
+  "hir/in-rust-tree",
+  "hir-def/in-rust-tree",
+  "hir-ty/in-rust-tree",
+  "load-cargo/in-rust-tree",
 ]
 
 [lints]
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/lib.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/lib.rs
index 8f74e75d3d3..7cf88e60dba 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/src/lib.rs
+++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/lib.rs
@@ -77,12 +77,19 @@ fn completion_item_hash(item: &CompletionItem, is_ref_completion: bool) -> [u8;
         }
     }
 
-    fn has_completion_relevance(hasher: &mut TentHasher, relevance: &CompletionRelevance) {
+    fn hash_completion_relevance(hasher: &mut TentHasher, relevance: &CompletionRelevance) {
         use ide_completion::{
             CompletionRelevancePostfixMatch, CompletionRelevanceReturnType,
             CompletionRelevanceTypeMatch,
         };
 
+        hasher.update(&[
+            u8::from(relevance.exact_name_match),
+            u8::from(relevance.is_local),
+            u8::from(relevance.is_name_already_imported),
+            u8::from(relevance.requires_import),
+            u8::from(relevance.is_private_editable),
+        ]);
         if let Some(type_match) = &relevance.type_match {
             let label = match type_match {
                 CompletionRelevanceTypeMatch::CouldUnify => "could_unify",
@@ -90,15 +97,9 @@ fn completion_item_hash(item: &CompletionItem, is_ref_completion: bool) -> [u8;
             };
             hasher.update(label);
         }
-        hasher.update(&[u8::from(relevance.exact_name_match), u8::from(relevance.is_local)]);
         if let Some(trait_) = &relevance.trait_ {
             hasher.update(&[u8::from(trait_.is_op_method), u8::from(trait_.notable_trait)]);
         }
-        hasher.update(&[
-            u8::from(relevance.is_name_already_imported),
-            u8::from(relevance.requires_import),
-            u8::from(relevance.is_private_editable),
-        ]);
         if let Some(postfix_match) = &relevance.postfix_match {
             let label = match postfix_match {
                 CompletionRelevancePostfixMatch::NonExact => "non_exact",
@@ -139,7 +140,7 @@ fn completion_item_hash(item: &CompletionItem, is_ref_completion: bool) -> [u8;
     if let Some(documentation) = &item.documentation {
         hasher.update(documentation.as_str());
     }
-    has_completion_relevance(&mut hasher, &item.relevance);
+    hash_completion_relevance(&mut hasher, &item.relevance);
     if let Some((mutability, text_size)) = &item.ref_match {
         hasher.update(mutability.as_keyword_for_ref());
         hasher.update(u32::from(*text_size).to_le_bytes());