Skip to content

Commit

Permalink
Improve lint message; add note for future autofixable updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nahuakang committed Feb 4, 2021
1 parent 78ef0f2 commit 2f8a8d3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/loops.rs
Expand Up @@ -2051,7 +2051,7 @@ fn check_manual_flatten<'tcx>(
);
diag.span_help(
inner_expr.span,
"also remove the `if let` statement in the for loop",
"...and remove the `if let` statement in the for loop",
);
}
);
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/manual_flatten.rs
Expand Up @@ -25,7 +25,7 @@ fn main() {
}

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

// Using the `None` variant should not trigger the lint
// Note: for an autofixable suggestion, the binding in the for loop has to take the
// name of the binding in the `if let`
let z = vec![Some(1), Some(2), Some(3)];
for n in z {
if n.is_none() {
Expand Down
10 changes: 5 additions & 5 deletions tests/ui/manual_flatten.stderr
Expand Up @@ -12,7 +12,7 @@ LL | | }
| |_____^
|
= note: `-D clippy::manual-flatten` implied by `-D warnings`
help: also remove the `if let` statement in the for loop
help: ...and remove the `if let` statement in the for loop
--> $DIR/manual_flatten.rs:7:9
|
LL | / if let Some(y) = n {
Expand All @@ -33,7 +33,7 @@ LL | | };
LL | | }
| |_____^
|
help: also remove the `if let` statement in the for loop
help: ...and remove the `if let` statement in the for loop
--> $DIR/manual_flatten.rs:15:9
|
LL | / if let Ok(n) = n {
Expand All @@ -54,7 +54,7 @@ LL | | }
LL | | }
| |_____^
|
help: also remove the `if let` statement in the for loop
help: ...and remove the `if let` statement in the for loop
--> $DIR/manual_flatten.rs:22:9
|
LL | / if let Ok(n) = n {
Expand All @@ -75,7 +75,7 @@ LL | | }
LL | | }
| |_____^
|
help: also remove the `if let` statement in the for loop
help: ...and remove the `if let` statement in the for loop
--> $DIR/manual_flatten.rs:32:9
|
LL | / if let Ok(n) = n {
Expand All @@ -96,7 +96,7 @@ LL | | }
LL | | }
| |_____^
|
help: also remove the `if let` statement in the for loop
help: ...and remove the `if let` statement in the for loop
--> $DIR/manual_flatten.rs:41:9
|
LL | / if let Some(m) = n {
Expand Down

0 comments on commit 2f8a8d3

Please sign in to comment.