mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Merge pull request #18587 from Veykril/push-urrlrursyrws
fix: Fix syntax fixup inserting unnecessary semicolons
This commit is contained in:
commit
8762a4f9be
@ -110,7 +110,8 @@ pub(crate) fn fixup_syntax(
|
||||
}
|
||||
},
|
||||
ast::ExprStmt(it) => {
|
||||
if it.semicolon_token().is_none() {
|
||||
let needs_semi = it.semicolon_token().is_none() && it.expr().map_or(false, |e| e.syntax().kind() != SyntaxKind::BLOCK_EXPR);
|
||||
if needs_semi {
|
||||
append.insert(node.clone().into(), vec![
|
||||
Leaf::Punct(Punct {
|
||||
char: ';',
|
||||
@ -905,6 +906,21 @@ fn foo() {
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn foo () {|| __ra_fixup}
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fixup_regression_() {
|
||||
check(
|
||||
r#"
|
||||
fn foo() {
|
||||
{}
|
||||
{}
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn foo () {{} {}}
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user