Skip to content

Commit 9cf57d0

Browse files
committed
fix(needles_return): correct span selection for text replacement
1 parent b499b7d commit 9cf57d0

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

clippy_lints/src/returns.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ fn check_final_expr<'tcx>(
286286
ExprKind::Match(_, arms, MatchSource::Normal) => {
287287
let match_ty = cx.typeck_results().expr_ty(peeled_drop_expr);
288288
for arm in arms.iter() {
289-
check_final_expr(cx, arm.body, semi_spans.clone(), RetReplacement::Empty, Some(match_ty));
289+
check_final_expr(cx, arm.body, semi_spans.clone(), RetReplacement::Unit, Some(match_ty));
290290
}
291291
},
292292
// if it's a whole block, check it

tests/ui/needless_return.fixed

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn test_void_if_fun(b: bool) {
8181
fn test_void_match(x: u32) {
8282
match x {
8383
0 => (),
84-
_ =>(),
84+
_ => (),
8585
}
8686
}
8787

@@ -91,7 +91,7 @@ fn test_nested_match(x: u32) {
9191
1 => {
9292
let _ = 42;
9393
},
94-
_ =>(),
94+
_ => (),
9595
}
9696
}
9797

@@ -196,7 +196,7 @@ async fn async_test_void_if_fun(b: bool) {
196196
async fn async_test_void_match(x: u32) {
197197
match x {
198198
0 => (),
199-
_ =>(),
199+
_ => (),
200200
}
201201
}
202202

tests/ui/needless_return.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ LL | | return;
118118
= help: remove `return`
119119

120120
error: unneeded `return` statement
121-
--> $DIR/needless_return.rs:87:13
121+
--> $DIR/needless_return.rs:87:14
122122
|
123123
LL | _ => return,
124-
| ^^^^^^^
124+
| ^^^^^^
125125
|
126126
= help: replace `return` with a unit value
127127

@@ -136,10 +136,10 @@ LL | | return;
136136
= help: remove `return`
137137

138138
error: unneeded `return` statement
139-
--> $DIR/needless_return.rs:98:13
139+
--> $DIR/needless_return.rs:98:14
140140
|
141141
LL | _ => return,
142-
| ^^^^^^^
142+
| ^^^^^^
143143
|
144144
= help: replace `return` with a unit value
145145

@@ -296,10 +296,10 @@ LL | | return;
296296
= help: remove `return`
297297

298298
error: unneeded `return` statement
299-
--> $DIR/needless_return.rs:207:13
299+
--> $DIR/needless_return.rs:207:14
300300
|
301301
LL | _ => return,
302-
| ^^^^^^^
302+
| ^^^^^^
303303
|
304304
= help: replace `return` with a unit value
305305

0 commit comments

Comments
 (0)