Skip to content

Commit 2f8a8d3

Browse files
committed
Improve lint message; add note for future autofixable updates
1 parent 78ef0f2 commit 2f8a8d3

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

clippy_lints/src/loops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2051,7 +2051,7 @@ fn check_manual_flatten<'tcx>(
20512051
);
20522052
diag.span_help(
20532053
inner_expr.span,
2054-
"also remove the `if let` statement in the for loop",
2054+
"...and remove the `if let` statement in the for loop",
20552055
);
20562056
}
20572057
);

tests/ui/manual_flatten.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn main() {
2525
}
2626

2727
// Test for loop over an implicit reference
28-
// Note: If `clippy::manual_flatten` is made autofixable, this case will
28+
// Note: if `clippy::manual_flatten` is made autofixable, this case will
2929
// lead to a follow-up lint `clippy::into_iter_on_ref`
3030
let z = &y;
3131
for n in z {
@@ -44,6 +44,8 @@ fn main() {
4444
}
4545

4646
// Using the `None` variant should not trigger the lint
47+
// Note: for an autofixable suggestion, the binding in the for loop has to take the
48+
// name of the binding in the `if let`
4749
let z = vec![Some(1), Some(2), Some(3)];
4850
for n in z {
4951
if n.is_none() {

tests/ui/manual_flatten.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ LL | | }
1212
| |_____^
1313
|
1414
= note: `-D clippy::manual-flatten` implied by `-D warnings`
15-
help: also remove the `if let` statement in the for loop
15+
help: ...and remove the `if let` statement in the for loop
1616
--> $DIR/manual_flatten.rs:7:9
1717
|
1818
LL | / if let Some(y) = n {
@@ -33,7 +33,7 @@ LL | | };
3333
LL | | }
3434
| |_____^
3535
|
36-
help: also remove the `if let` statement in the for loop
36+
help: ...and remove the `if let` statement in the for loop
3737
--> $DIR/manual_flatten.rs:15:9
3838
|
3939
LL | / if let Ok(n) = n {
@@ -54,7 +54,7 @@ LL | | }
5454
LL | | }
5555
| |_____^
5656
|
57-
help: also remove the `if let` statement in the for loop
57+
help: ...and remove the `if let` statement in the for loop
5858
--> $DIR/manual_flatten.rs:22:9
5959
|
6060
LL | / if let Ok(n) = n {
@@ -75,7 +75,7 @@ LL | | }
7575
LL | | }
7676
| |_____^
7777
|
78-
help: also remove the `if let` statement in the for loop
78+
help: ...and remove the `if let` statement in the for loop
7979
--> $DIR/manual_flatten.rs:32:9
8080
|
8181
LL | / if let Ok(n) = n {
@@ -96,7 +96,7 @@ LL | | }
9696
LL | | }
9797
| |_____^
9898
|
99-
help: also remove the `if let` statement in the for loop
99+
help: ...and remove the `if let` statement in the for loop
100100
--> $DIR/manual_flatten.rs:41:9
101101
|
102102
LL | / if let Some(m) = n {

0 commit comments

Comments
 (0)