Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/render.rs')
-rw-r--r--crates/ide-completion/src/render.rs41
1 files changed, 24 insertions, 17 deletions
diff --git a/crates/ide-completion/src/render.rs b/crates/ide-completion/src/render.rs
index a636c0603b..7e6e76541e 100644
--- a/crates/ide-completion/src/render.rs
+++ b/crates/ide-completion/src/render.rs
@@ -828,7 +828,7 @@ mod tests {
items.push(format!(
"{tag} {} {} {relevance}\n",
it.label.primary,
- it.label.detail_right.clone().unwrap_or_default(),
+ it.label.detail_right.as_deref().unwrap_or_default(),
));
if let Some((label, _indel, relevance)) = it.ref_match() {
@@ -844,24 +844,31 @@ mod tests {
expect.assert_eq(&actual);
fn display_relevance(relevance: CompletionRelevance) -> String {
- let relevance_factors = vec![
- (relevance.type_match == Some(CompletionRelevanceTypeMatch::Exact), "type"),
- (
- relevance.type_match == Some(CompletionRelevanceTypeMatch::CouldUnify),
- "type_could_unify",
- ),
- (relevance.exact_name_match, "name"),
- (relevance.is_local, "local"),
- (
- relevance.postfix_match == Some(CompletionRelevancePostfixMatch::Exact),
- "snippet",
- ),
- (relevance.trait_.is_some_and(|it| it.is_op_method), "op_method"),
- (relevance.requires_import, "requires_import"),
- (relevance.has_local_inherent_impl, "has_local_inherent_impl"),
+ let CompletionRelevance {
+ exact_name_match,
+ type_match,
+ is_local,
+ trait_,
+ is_name_already_imported: _,
+ requires_import,
+ is_private_editable: _,
+ postfix_match,
+ function: _,
+ is_skipping_completion: _,
+ has_local_inherent_impl,
+ } = relevance;
+ let relevance_factors = [
+ (type_match == Some(CompletionRelevanceTypeMatch::Exact), "type"),
+ (type_match == Some(CompletionRelevanceTypeMatch::CouldUnify), "type_could_unify"),
+ (exact_name_match, "name"),
+ (is_local, "local"),
+ (postfix_match == Some(CompletionRelevancePostfixMatch::Exact), "snippet"),
+ (trait_.is_some_and(|it| it.is_op_method), "op_method"),
+ (requires_import, "requires_import"),
+ (has_local_inherent_impl, "has_local_inherent_impl"),
]
.into_iter()
- .filter_map(|(cond, desc)| if cond { Some(desc) } else { None })
+ .filter_map(|(cond, desc)| cond.then_some(desc))
.join("+");
format!("[{relevance_factors}]")