From a5147e8a0819dd1daab28a3ef1970069396a5bf1 Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Fri, 18 Aug 2017 17:12:00 +0300 Subject: [PATCH] is_from_for_loop: document what first check matches Removing the first check will break a lot of for-loop UI tests and the dogfood test. --- clippy_lints/src/utils/higher.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/clippy_lints/src/utils/higher.rs b/clippy_lints/src/utils/higher.rs index 3665bdf2360..67319f0c355 100644 --- a/clippy_lints/src/utils/higher.rs +++ b/clippy_lints/src/utils/higher.rs @@ -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, -- 2.44.0