Skip to content

Commit 54a1a96

Browse files
authored
Merge pull request rust-lang#18587 from Veykril/push-urrlrursyrws
fix: Fix syntax fixup inserting unnecessary semicolons
2 parents 0946570 + 03ae70d commit 54a1a96

File tree

1 file changed

+17
-1
lines changed
  • src/tools/rust-analyzer/crates/hir-expand/src

1 file changed

+17
-1
lines changed

src/tools/rust-analyzer/crates/hir-expand/src/fixup.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ pub(crate) fn fixup_syntax(
110110
}
111111
},
112112
ast::ExprStmt(it) => {
113-
if it.semicolon_token().is_none() {
113+
let needs_semi = it.semicolon_token().is_none() && it.expr().map_or(false, |e| e.syntax().kind() != SyntaxKind::BLOCK_EXPR);
114+
if needs_semi {
114115
append.insert(node.clone().into(), vec![
115116
Leaf::Punct(Punct {
116117
char: ';',
@@ -905,6 +906,21 @@ fn foo() {
905906
"#,
906907
expect![[r#"
907908
fn foo () {|| __ra_fixup}
909+
"#]],
910+
);
911+
}
912+
913+
#[test]
914+
fn fixup_regression_() {
915+
check(
916+
r#"
917+
fn foo() {
918+
{}
919+
{}
920+
}
921+
"#,
922+
expect![[r#"
923+
fn foo () {{} {}}
908924
"#]],
909925
);
910926
}

0 commit comments

Comments
 (0)