diff --git a/clippy_lints/src/option_map_unit_fn.rs b/clippy_lints/src/option_map_unit_fn.rs index df3c78a344b7..b383f54993cf 100644 --- a/clippy_lints/src/option_map_unit_fn.rs +++ b/clippy_lints/src/option_map_unit_fn.rs @@ -97,17 +97,7 @@ fn reduce_unit_expression<'a>(cx: &LateContext, expr: &'a hir::Expr) -> Option Some(d.span), hir::StmtExpr(ref e, _) => Some(e.span), - hir::StmtSemi(ref e, _) => { - if is_unit_expression(cx, e) { - // `X` returns unit so we can strip the - // semicolon and reduce further - reduce_unit_expression(cx, e) - } else { - // `X` doesn't return unit so it needs a - // trailing semicolon - Some(inner_stmt.span) - } - }, + hir::StmtSemi(_, _) => Some(inner_stmt.span), } }, _ => None, diff --git a/tests/ui/option_map_unit_fn.stderr b/tests/ui/option_map_unit_fn.stderr index ee0945d95037..84dedf9cd604 100644 --- a/tests/ui/option_map_unit_fn.stderr +++ b/tests/ui/option_map_unit_fn.stderr @@ -62,7 +62,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure 52 | x.field.map(|value| { do_nothing(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | - | help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }` + | help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:54:5 @@ -70,7 +70,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure 54 | x.field.map(|value| { { do_nothing(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | - | help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }` + | help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:57:5 @@ -94,7 +94,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure 61 | x.field.map(|value| { diverge(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | - | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` + | help: try this: `if let Some(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:63:5 @@ -102,7 +102,7 @@ error: called `map(f)` on an Option value where `f` is a unit closure 63 | x.field.map(|value| { { diverge(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | - | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` + | help: try this: `if let Some(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:68:5