fix: Fix syntax fixup inserting unnecessary semicolons
This commit is contained in:
parent
b747197a82
commit
03ae70dcac
1 changed files with 17 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue