Skip to content

Commit 006c442

Browse files
committed
check whether stmts is empty or not in block
1 parent e34927e commit 006c442

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clippy_lints/src/methods/option_map_or_none.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ fn reduce_unit_expression<'a>(
2020
match expr.kind {
2121
hir::ExprKind::Call(func, arg_char) => Some((func, arg_char)),
2222
hir::ExprKind::Block(block, _) => {
23-
match block.expr {
24-
Some(inner_expr) => {
23+
match (block.stmts, block.expr) {
24+
(&[], Some(inner_expr)) => {
2525
// If block only contains an expression,
2626
// reduce `|x| { x + 1 }` to `|x| x + 1`
2727
reduce_unit_expression(cx, inner_expr)

0 commit comments

Comments
 (0)