Skip to content

Commit f68fd66

Browse files
Fix logical error in relevance scoring implementation
1 parent c4f727b commit f68fd66

File tree

1 file changed

+3
-3
lines changed
  • src/tools/rust-analyzer/crates/ide-completion/src

1 file changed

+3
-3
lines changed

src/tools/rust-analyzer/crates/ide-completion/src/item.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,14 @@ impl CompletionRelevance {
252252
/// Provides a relevance score. Higher values are more relevant.
253253
///
254254
/// The absolute value of the relevance score is not meaningful, for
255-
/// example a value of 0 doesn't mean "not relevant", rather
255+
/// example a value of (!(0 as u32) / 2) doesn't mean "not relevant", rather
256256
/// it means "least relevant". The score value should only be used
257257
/// for relative ordering.
258258
///
259259
/// See is_relevant if you need to make some judgement about score
260260
/// in an absolute sense.
261261
pub fn score(self) -> u32 {
262-
let mut score = !0 / 2;
262+
let mut score = !(0 as u32) / 2;
263263
let CompletionRelevance {
264264
exact_name_match,
265265
type_match,
@@ -350,7 +350,7 @@ impl CompletionRelevance {
350350
/// some threshold such that we think it is especially likely
351351
/// to be relevant.
352352
pub fn is_relevant(&self) -> bool {
353-
self.score() > (!0 / 2)
353+
self.score() > !(0 as u32) / 2
354354
}
355355
}
356356

0 commit comments

Comments
 (0)