Skip to content

Commit ab81011

Browse files
committed
Force to use block for body of closure when it contains comment
1 parent 9de9693 commit ab81011

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/expr.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -899,9 +899,6 @@ fn rewrite_cond(context: &RewriteContext, expr: &ast::Expr, shape: Shape) -> Opt
899899
};
900900
cond.rewrite(context, cond_shape)
901901
}
902-
ast::ExprKind::Block(ref block) if block.stmts.len() == 1 => {
903-
stmt_expr(&block.stmts[0]).and_then(|e| rewrite_cond(context, e, shape))
904-
}
905902
_ => to_control_flow(expr, ExprType::SubExpression).and_then(|control_flow| {
906903
let alt_block_sep =
907904
String::from("\n") + &shape.indent.block_only().to_string(context.config);
@@ -2219,7 +2216,7 @@ fn rewrite_last_closure(
22192216
) -> Option<String> {
22202217
if let ast::ExprKind::Closure(capture, ref fn_decl, ref body, _) = expr.node {
22212218
let body = match body.node {
2222-
ast::ExprKind::Block(ref block) if block.stmts.len() == 1 => {
2219+
ast::ExprKind::Block(ref block) if is_simple_block(block, context.codemap) => {
22232220
stmt_expr(&block.stmts[0]).unwrap_or(body)
22242221
}
22252222
_ => body,

0 commit comments

Comments
 (0)