about summary refs log tree commit diff
diff options
context:
space:
mode:
authornahuakang <kangnahua@gmail.com>2021-02-04 10:51:40 +0100
committernahuakang <kangnahua@gmail.com>2021-02-04 10:51:40 +0100
commit2f8a8d3468050f724473900bcfcc75a110314059 (patch)
treeeaa4aee5911a318a13bf203575aab44aa906b664
parent78ef0f2f6c17f5933ab4dbab544b76f7da742467 (diff)
downloadrust-2f8a8d3468050f724473900bcfcc75a110314059.tar.gz
rust-2f8a8d3468050f724473900bcfcc75a110314059.zip
Improve lint message; add note for future autofixable updates
-rw-r--r--clippy_lints/src/loops.rs2
-rw-r--r--tests/ui/manual_flatten.rs4
-rw-r--r--tests/ui/manual_flatten.stderr10
3 files changed, 9 insertions, 7 deletions
diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs
index 817230a29c6..663c2df23e2 100644
--- a/clippy_lints/src/loops.rs
+++ b/clippy_lints/src/loops.rs
@@ -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",
                         );
                     }
                 );
diff --git a/tests/ui/manual_flatten.rs b/tests/ui/manual_flatten.rs
index ea3440f6da2..cff68eca933 100644
--- a/tests/ui/manual_flatten.rs
+++ b/tests/ui/manual_flatten.rs
@@ -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 {
@@ -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() {
diff --git a/tests/ui/manual_flatten.stderr b/tests/ui/manual_flatten.stderr
index 49b8ed0564a..855dd9130e2 100644
--- a/tests/ui/manual_flatten.stderr
+++ b/tests/ui/manual_flatten.stderr
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {