We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3e61326 commit bd4dc36Copy full SHA for bd4dc36
src/expr.rs
@@ -1173,14 +1173,21 @@ pub(crate) fn is_simple_block_stmt(
1173
&& attrs.map_or(true, |a| a.is_empty())
1174
}
1175
1176
+fn block_has_statements(block: &ast::Block) -> bool {
1177
+ block
1178
+ .stmts
1179
+ .iter()
1180
+ .any(|stmt| !matches!(stmt.kind, ast::StmtKind::Empty))
1181
+}
1182
+
1183
/// Checks whether a block contains no statements, expressions, comments, or
1184
/// inner attributes.
1185
pub(crate) fn is_empty_block(
1186
context: &RewriteContext<'_>,
1187
block: &ast::Block,
1188
attrs: Option<&[ast::Attribute]>,
1189
) -> bool {
- block.stmts.is_empty()
1190
+ !block_has_statements(&block)
1191
&& !block_contains_comment(context, block)
1192
&& attrs.map_or(true, |a| inner_attributes(a).is_empty())
1193
0 commit comments