Skip to content

Commit e4d3b8f

Browse files
committed
misc improvements
1 parent 400c929 commit e4d3b8f

3 files changed

Lines changed: 30 additions & 23 deletions

File tree

crates/ide-completion/src/context/analysis.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,12 +2094,12 @@ fn next_non_trivia_token(e: impl Into<SyntaxElement>) -> Option<SyntaxToken> {
20942094
}
20952095

20962096
fn next_non_trivia_sibling(ele: SyntaxElement) -> Option<SyntaxElement> {
2097-
let mut e = ele.next_sibling_or_token();
2098-
while let Some(inner) = e {
2099-
if !inner.kind().is_trivia() {
2100-
return Some(inner);
2097+
let mut e = ele;
2098+
while let Some(next) = e.next_sibling_or_token() {
2099+
if !next.kind().is_trivia() {
2100+
return Some(next);
21012101
} else {
2102-
e = inner.next_sibling_or_token();
2102+
e = next;
21032103
}
21042104
}
21052105
None

crates/ide-completion/src/render.rs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ mod tests {
828828
items.push(format!(
829829
"{tag} {} {} {relevance}\n",
830830
it.label.primary,
831-
it.label.detail_right.clone().unwrap_or_default(),
831+
it.label.detail_right.as_deref().unwrap_or_default(),
832832
));
833833

834834
if let Some((label, _indel, relevance)) = it.ref_match() {
@@ -844,24 +844,31 @@ mod tests {
844844
expect.assert_eq(&actual);
845845

846846
fn display_relevance(relevance: CompletionRelevance) -> String {
847-
let relevance_factors = vec![
848-
(relevance.type_match == Some(CompletionRelevanceTypeMatch::Exact), "type"),
849-
(
850-
relevance.type_match == Some(CompletionRelevanceTypeMatch::CouldUnify),
851-
"type_could_unify",
852-
),
853-
(relevance.exact_name_match, "name"),
854-
(relevance.is_local, "local"),
855-
(
856-
relevance.postfix_match == Some(CompletionRelevancePostfixMatch::Exact),
857-
"snippet",
858-
),
859-
(relevance.trait_.is_some_and(|it| it.is_op_method), "op_method"),
860-
(relevance.requires_import, "requires_import"),
861-
(relevance.has_local_inherent_impl, "has_local_inherent_impl"),
847+
let CompletionRelevance {
848+
exact_name_match,
849+
type_match,
850+
is_local,
851+
trait_,
852+
is_name_already_imported: _,
853+
requires_import,
854+
is_private_editable: _,
855+
postfix_match,
856+
function: _,
857+
is_skipping_completion: _,
858+
has_local_inherent_impl,
859+
} = relevance;
860+
let relevance_factors = [
861+
(type_match == Some(CompletionRelevanceTypeMatch::Exact), "type"),
862+
(type_match == Some(CompletionRelevanceTypeMatch::CouldUnify), "type_could_unify"),
863+
(exact_name_match, "name"),
864+
(is_local, "local"),
865+
(postfix_match == Some(CompletionRelevancePostfixMatch::Exact), "snippet"),
866+
(trait_.is_some_and(|it| it.is_op_method), "op_method"),
867+
(requires_import, "requires_import"),
868+
(has_local_inherent_impl, "has_local_inherent_impl"),
862869
]
863870
.into_iter()
864-
.filter_map(|(cond, desc)| if cond { Some(desc) } else { None })
871+
.filter_map(|(cond, desc)| cond.then_some(desc))
865872
.join("+");
866873

867874
format!("[{relevance_factors}]")

crates/ide-db/src/imports/import_assets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ pub struct LocatedImport {
314314
pub item_to_import: ItemInNs,
315315
/// The path import candidate, resolved.
316316
///
317-
/// Not necessary matches the import:
317+
/// Not necessarily matches the import:
318318
/// For any associated constant from the trait, we try to access as `some::path::SomeStruct::ASSOC_`
319319
/// the original item is the associated constant, but the import has to be a trait that
320320
/// defines this constant.

0 commit comments

Comments
 (0)