about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTongjun Gao <natural_selection_@outlook.com>2025-03-07 13:24:14 +0800
committerTongjun Gao <natural_selection_@outlook.com>2025-03-07 14:21:57 +0800
commitf68fd669f3d7a0847b5c2f3b789b6c95db0acdc1 (patch)
tree5f0f9f0e2e43ee9b12700a48f37e5d98a8bedfe6
parentc4f727bfb8640e9ddd4f66b562bba7a0d7b4f46c (diff)
downloadrust-f68fd669f3d7a0847b5c2f3b789b6c95db0acdc1.tar.gz
rust-f68fd669f3d7a0847b5c2f3b789b6c95db0acdc1.zip
Fix logical error in relevance scoring implementation
-rw-r--r--src/tools/rust-analyzer/crates/ide-completion/src/item.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/item.rs b/src/tools/rust-analyzer/crates/ide-completion/src/item.rs
index ea52d69c795..294fbde1b6d 100644
--- a/src/tools/rust-analyzer/crates/ide-completion/src/item.rs
+++ b/src/tools/rust-analyzer/crates/ide-completion/src/item.rs
@@ -252,14 +252,14 @@ impl CompletionRelevance {
     /// Provides a relevance score. Higher values are more relevant.
     ///
     /// The absolute value of the relevance score is not meaningful, for
-    /// example a value of 0 doesn't mean "not relevant", rather
+    /// example a value of (!(0 as u32) / 2) doesn't mean "not relevant", rather
     /// it means "least relevant". The score value should only be used
     /// for relative ordering.
     ///
     /// See is_relevant if you need to make some judgement about score
     /// in an absolute sense.
     pub fn score(self) -> u32 {
-        let mut score = !0 / 2;
+        let mut score = !(0 as u32) / 2;
         let CompletionRelevance {
             exact_name_match,
             type_match,
@@ -350,7 +350,7 @@ impl CompletionRelevance {
     /// some threshold such that we think it is especially likely
     /// to be relevant.
     pub fn is_relevant(&self) -> bool {
-        self.score() > (!0 / 2)
+        self.score() > !(0 as u32) / 2
     }
 }