diff options
| author | bors <bors@rust-lang.org> | 2019-07-09 09:10:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-07-09 09:10:07 +0000 |
| commit | 1987bf73a8e9e9cc84d6e5d31c607b5fce84d6ae (patch) | |
| tree | 8d7ca21695cc8c41f8b7989aa72d87e5be90dcd4 | |
| parent | 316da7eb41f2c263963fc1b74fe9bb528860817f (diff) | |
| parent | 2fb73fe03782f1485e6e2305afa66edec7f26d83 (diff) | |
| download | rust-1987bf73a8e9e9cc84d6e5d31c607b5fce84d6ae.tar.gz rust-1987bf73a8e9e9cc84d6e5d31c607b5fce84d6ae.zip | |
Auto merge of #4262 - bara86:master, r=flip1995
Use empty block instead of unit type for needless return fixes #4238 changelog: Use empty block instead of unit type for needless return
| -rw-r--r-- | clippy_lints/src/returns.rs | 10 | ||||
| -rw-r--r-- | tests/ui/needless_return.stderr | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index 2245b719c23..f08945b53d5 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -86,7 +86,7 @@ declare_clippy_lint! { #[derive(PartialEq, Eq, Copy, Clone)] enum RetReplacement { Empty, - Unit, + Block, } declare_lint_pass!(Return => [NEEDLESS_RETURN, LET_AND_RETURN, UNUSED_UNIT]); @@ -139,7 +139,7 @@ impl Return { // a match expr, check all arms ast::ExprKind::Match(_, ref arms) => { for arm in arms { - self.check_final_expr(cx, &arm.body, Some(arm.body.span), RetReplacement::Unit); + self.check_final_expr(cx, &arm.body, Some(arm.body.span), RetReplacement::Block); } }, _ => (), @@ -176,12 +176,12 @@ impl Return { ); }); }, - RetReplacement::Unit => { + RetReplacement::Block => { span_lint_and_then(cx, NEEDLESS_RETURN, ret_span, "unneeded return statement", |db| { db.span_suggestion( ret_span, - "replace `return` with the unit type", - "()".to_string(), + "replace `return` with an empty block", + "{}".to_string(), Applicability::MachineApplicable, ); }); diff --git a/tests/ui/needless_return.stderr b/tests/ui/needless_return.stderr index 7858ecfba97..ee700ab8408 100644 --- a/tests/ui/needless_return.stderr +++ b/tests/ui/needless_return.stderr @@ -70,7 +70,7 @@ error: unneeded return statement --> $DIR/needless_return.rs:64:14 | LL | _ => return, - | ^^^^^^ help: replace `return` with the unit type: `()` + | ^^^^^^ help: replace `return` with an empty block: `{}` error: aborting due to 12 previous errors |
