diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index b8172b74dc01..df126d7617eb 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -286,7 +286,7 @@ fn check_final_expr<'tcx>( ExprKind::Match(_, arms, MatchSource::Normal) => { let match_ty = cx.typeck_results().expr_ty(peeled_drop_expr); for arm in arms.iter() { - check_final_expr(cx, arm.body, semi_spans.clone(), RetReplacement::Empty, Some(match_ty)); + check_final_expr(cx, arm.body, semi_spans.clone(), RetReplacement::Unit, Some(match_ty)); } }, // if it's a whole block, check it diff --git a/tests/ui/needless_return.fixed b/tests/ui/needless_return.fixed index 47a9f031a42c..57c08996ce25 100644 --- a/tests/ui/needless_return.fixed +++ b/tests/ui/needless_return.fixed @@ -81,7 +81,7 @@ fn test_void_if_fun(b: bool) { fn test_void_match(x: u32) { match x { 0 => (), - _ =>(), + _ => (), } } @@ -91,7 +91,7 @@ fn test_nested_match(x: u32) { 1 => { let _ = 42; }, - _ =>(), + _ => (), } } @@ -196,7 +196,7 @@ async fn async_test_void_if_fun(b: bool) { async fn async_test_void_match(x: u32) { match x { 0 => (), - _ =>(), + _ => (), } } diff --git a/tests/ui/needless_return.stderr b/tests/ui/needless_return.stderr index 5d471a3c5214..87d0cd3e14cf 100644 --- a/tests/ui/needless_return.stderr +++ b/tests/ui/needless_return.stderr @@ -118,10 +118,10 @@ LL | | return; = help: remove `return` error: unneeded `return` statement - --> $DIR/needless_return.rs:87:13 + --> $DIR/needless_return.rs:87:14 | LL | _ => return, - | ^^^^^^^ + | ^^^^^^ | = help: replace `return` with a unit value @@ -136,10 +136,10 @@ LL | | return; = help: remove `return` error: unneeded `return` statement - --> $DIR/needless_return.rs:98:13 + --> $DIR/needless_return.rs:98:14 | LL | _ => return, - | ^^^^^^^ + | ^^^^^^ | = help: replace `return` with a unit value @@ -296,10 +296,10 @@ LL | | return; = help: remove `return` error: unneeded `return` statement - --> $DIR/needless_return.rs:207:13 + --> $DIR/needless_return.rs:207:14 | LL | _ => return, - | ^^^^^^^ + | ^^^^^^ | = help: replace `return` with a unit value