Skip to content

Commit

Permalink
chore: backport some empty block check fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
calebcartwright committed Jan 28, 2021
1 parent bd4dc36 commit c13d245
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ fn rewrite_empty_block(
prefix: &str,
shape: Shape,
) -> Option<String> {
if !block.stmts.is_empty() {
if block_has_statements(&block) {
return None;
}

Expand Down
13 changes: 13 additions & 0 deletions tests/source/issue_3868.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fn foo() {
;
}

fn bar() {
for _ in 0..1 {
;
}
}

fn baz() {
();
}
9 changes: 9 additions & 0 deletions tests/target/issue_3868.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fn foo() {}

fn bar() {
for _ in 0..1 {}
}

fn baz() {
();
}

0 comments on commit c13d245

Please sign in to comment.