Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 160cb32

Browse files
Unite more bool hashing
1 parent 78ea49e commit 160cb32

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

src/tools/rust-analyzer/crates/rust-analyzer/Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ jemalloc = ["jemallocator", "profile/jemalloc"]
9292
force-always-assert = ["always-assert/force"]
9393
sysroot-abi = []
9494
in-rust-tree = [
95-
"sysroot-abi",
96-
"syntax/in-rust-tree",
97-
"parser/in-rust-tree",
98-
"hir/in-rust-tree",
99-
"hir-def/in-rust-tree",
100-
"hir-ty/in-rust-tree",
101-
"load-cargo/in-rust-tree",
95+
"sysroot-abi",
96+
"syntax/in-rust-tree",
97+
"parser/in-rust-tree",
98+
"hir/in-rust-tree",
99+
"hir-def/in-rust-tree",
100+
"hir-ty/in-rust-tree",
101+
"load-cargo/in-rust-tree",
102102
]
103103

104104
[lints]

src/tools/rust-analyzer/crates/rust-analyzer/src/lib.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,28 +77,29 @@ fn completion_item_hash(item: &CompletionItem, is_ref_completion: bool) -> [u8;
7777
}
7878
}
7979

80-
fn has_completion_relevance(hasher: &mut TentHasher, relevance: &CompletionRelevance) {
80+
fn hash_completion_relevance(hasher: &mut TentHasher, relevance: &CompletionRelevance) {
8181
use ide_completion::{
8282
CompletionRelevancePostfixMatch, CompletionRelevanceReturnType,
8383
CompletionRelevanceTypeMatch,
8484
};
8585

86+
hasher.update(&[
87+
u8::from(relevance.exact_name_match),
88+
u8::from(relevance.is_local),
89+
u8::from(relevance.is_name_already_imported),
90+
u8::from(relevance.requires_import),
91+
u8::from(relevance.is_private_editable),
92+
]);
8693
if let Some(type_match) = &relevance.type_match {
8794
let label = match type_match {
8895
CompletionRelevanceTypeMatch::CouldUnify => "could_unify",
8996
CompletionRelevanceTypeMatch::Exact => "exact",
9097
};
9198
hasher.update(label);
9299
}
93-
hasher.update(&[u8::from(relevance.exact_name_match), u8::from(relevance.is_local)]);
94100
if let Some(trait_) = &relevance.trait_ {
95101
hasher.update(&[u8::from(trait_.is_op_method), u8::from(trait_.notable_trait)]);
96102
}
97-
hasher.update(&[
98-
u8::from(relevance.is_name_already_imported),
99-
u8::from(relevance.requires_import),
100-
u8::from(relevance.is_private_editable),
101-
]);
102103
if let Some(postfix_match) = &relevance.postfix_match {
103104
let label = match postfix_match {
104105
CompletionRelevancePostfixMatch::NonExact => "non_exact",
@@ -139,7 +140,7 @@ fn completion_item_hash(item: &CompletionItem, is_ref_completion: bool) -> [u8;
139140
if let Some(documentation) = &item.documentation {
140141
hasher.update(documentation.as_str());
141142
}
142-
has_completion_relevance(&mut hasher, &item.relevance);
143+
hash_completion_relevance(&mut hasher, &item.relevance);
143144
if let Some((mutability, text_size)) = &item.ref_match {
144145
hasher.update(mutability.as_keyword_for_ref());
145146
hasher.update(u32::from(*text_size).to_le_bytes());

0 commit comments

Comments
 (0)