Skip to content

Commit 02c9b7c

Browse files
authored
Merge pull request rust-lang#19307 from Natural-selection1/master
Fix logical error in PR rust-lang#19297
2 parents c4f727b + 16878eb commit 02c9b7c

File tree

1 file changed

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

1 file changed

+5
-3
lines changed

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,16 @@ 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 BASE_SCORE 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.
261+
const BASE_SCORE: u32 = u32::MAX / 2;
262+
261263
pub fn score(self) -> u32 {
262-
let mut score = !0 / 2;
264+
let mut score = Self::BASE_SCORE;
263265
let CompletionRelevance {
264266
exact_name_match,
265267
type_match,
@@ -350,7 +352,7 @@ impl CompletionRelevance {
350352
/// some threshold such that we think it is especially likely
351353
/// to be relevant.
352354
pub fn is_relevant(&self) -> bool {
353-
self.score() > (!0 / 2)
355+
self.score() > Self::BASE_SCORE
354356
}
355357
}
356358

0 commit comments

Comments
 (0)