Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions src/formatting/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1206,18 +1206,10 @@ pub(crate) fn is_simple_block_stmt(
}

fn block_has_statements(block: &ast::Block) -> bool {
block.stmts.iter().any(|stmt| match stmt.kind {
ast::StmtKind::Semi(ref expr) => {
if let ast::ExprKind::Tup(ref tup_exprs) = expr.kind {
if tup_exprs.is_empty() {
return false;
}
}
true
}
ast::StmtKind::Empty => false,
_ => true,
})
!block
.stmts
.iter()
.all(|stmt| matches!(stmt.kind, ast::StmtKind::Empty))
}

/// Checks whether a block contains no statements, expressions, comments, or
Expand Down
4 changes: 3 additions & 1 deletion tests/target/issue_3868.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ fn bar() {
for _ in 0..1 {}
}

fn baz() {}
fn baz() {
();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were only doing this before because at the time this issue was resolved the rustc parser/AST didn't allow us to differentiate between these empty tuple exprs in statement position and a plain old empty semi ;

}