]> git.lizzy.rs Git - rust.git/commitdiff
is_from_for_loop: document what first check matches
authorJoonas Koivunen <joonas.koivunen@gmail.com>
Fri, 18 Aug 2017 14:12:00 +0000 (17:12 +0300)
committerJoonas Koivunen <joonas.koivunen@gmail.com>
Fri, 18 Aug 2017 14:12:00 +0000 (17:12 +0300)
Removing the first check will break a lot of for-loop UI tests and the
dogfood test.

clippy_lints/src/utils/higher.rs

index 3665bdf2360384a71f515a67e77a08b0bb03d7f4..67319f0c35512cbe2665594f1a9d5466df39424f 100644 (file)
@@ -114,6 +114,13 @@ fn get_field<'a>(name: &str, fields: &'a [hir::Field]) -> Option<&'a hir::Expr>
 
 /// Checks if a `let` decl is from a `for` loop desugaring.
 pub fn is_from_for_desugar(decl: &hir::Decl) -> bool {
+    // This will detect plain for-loops without an actual variable binding:
+    //
+    // ```
+    // for x in some_vec {
+    //   // do stuff
+    // }
+    // ```
     if_let_chain! {[
         let hir::DeclLocal(ref loc) = decl.node,
         let Some(ref expr) = loc.init,