Merge pull request #21402 from A4-Tacks/no-semicolon-array

Fix complete semicolon in array expression
This commit is contained in:
Chayim Refael Friedman
2026-02-12 20:10:46 +00:00
committed by GitHub
2 changed files with 23 additions and 1 deletions

View File

@@ -821,7 +821,10 @@ impl<'db> CompletionContext<'db> {
CompleteSemicolon::DoNotComplete
} else if let Some(term_node) =
sema.token_ancestors_with_macros(token.clone()).find(|node| {
matches!(node.kind(), BLOCK_EXPR | MATCH_ARM | CLOSURE_EXPR | ARG_LIST | PAREN_EXPR)
matches!(
node.kind(),
BLOCK_EXPR | MATCH_ARM | CLOSURE_EXPR | ARG_LIST | PAREN_EXPR | ARRAY_EXPR
)
})
{
let next_token = iter::successors(token.next_token(), |it| it.next_token())

View File

@@ -905,6 +905,25 @@ fn baz(_: impl FnOnce()) {}
fn bar() {
baz(foo()$0);
}
"#,
);
}
#[test]
fn no_semicolon_in_array() {
check_edit(
r#"foo"#,
r#"
fn foo() {}
fn bar() {
let _ = [fo$0];
}
"#,
r#"
fn foo() {}
fn bar() {
let _ = [foo()$0];
}
"#,
);
}