diff options
| author | togami2864 <tuabobo123@gmail.com> | 2021-11-18 00:36:11 +0900 |
|---|---|---|
| committer | togami2864 <tuabobo123@gmail.com> | 2021-11-18 00:36:11 +0900 |
| commit | 006c4426577bf243f7218f951d0c9ada6b4fe737 (patch) | |
| tree | 2ac4f3281a4ac10d60ddc74047d51e369e28a8d4 | |
| parent | e34927ecf66500858facab9b4ad0cdfa757318aa (diff) | |
| download | rust-006c4426577bf243f7218f951d0c9ada6b4fe737.tar.gz rust-006c4426577bf243f7218f951d0c9ada6b4fe737.zip | |
check whether stmts is empty or not in block
| -rw-r--r-- | clippy_lints/src/methods/option_map_or_none.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clippy_lints/src/methods/option_map_or_none.rs b/clippy_lints/src/methods/option_map_or_none.rs index b5652838892..5e5c1038e82 100644 --- a/clippy_lints/src/methods/option_map_or_none.rs +++ b/clippy_lints/src/methods/option_map_or_none.rs @@ -20,8 +20,8 @@ fn reduce_unit_expression<'a>( match expr.kind { hir::ExprKind::Call(func, arg_char) => Some((func, arg_char)), hir::ExprKind::Block(block, _) => { - match block.expr { - Some(inner_expr) => { + match (block.stmts, block.expr) { + (&[], Some(inner_expr)) => { // If block only contains an expression, // reduce `|x| { x + 1 }` to `|x| x + 1` reduce_unit_expression(cx, inner_expr) |
