fix(needles_return): correct span selection for text replacement

This commit is contained in:
feniljain 2023-04-05 20:03:45 +05:30
parent b499b7dc73
commit 9cf57d0a8f
3 changed files with 10 additions and 10 deletions

View File

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

View File

@ -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 => (),
_ =>(),
_ => (),
}
}

View File

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