mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2026-04-11 21:14:30 +00:00
Merge pull request #21402 from A4-Tacks/no-semicolon-array
Fix complete semicolon in array expression
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user