Remove further semicolon reduction

This commit is contained in:
Philipp Hansch 2018-04-10 22:13:58 +02:00
parent db60c67c5b
commit 7de707fdba
No known key found for this signature in database
GPG key ID: B6FA06A6E0E2665B
2 changed files with 5 additions and 15 deletions

View file

@ -97,17 +97,7 @@ fn reduce_unit_expression<'a>(cx: &LateContext, expr: &'a hir::Expr) -> Option<S
match inner_stmt.node {
hir::StmtDecl(ref d, _) => 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,

View file

@ -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