about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2019-10-01 11:30:22 -0700
committerGitHub <noreply@github.com>2019-10-01 11:30:22 -0700
commitb462905cc91ce58b073ef820c0265874ae0c2682 (patch)
tree0f1105197eb88f376fbc0d3d4b7509124ba91492
parent406e89a00c3cca86abe619b703f192bf699f92f6 (diff)
parent9e166e09b8e4883ba6b47e190e2e7b8b72126c6f (diff)
downloadrust-b462905cc91ce58b073ef820c0265874ae0c2682.tar.gz
rust-b462905cc91ce58b073ef820c0265874ae0c2682.zip
Merge pull request #4604 from Manishearth/rustup
Rustup to rustc 1.40.0-nightly (702b45e40 2019-10-01)
-rw-r--r--clippy_lints/src/loops.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs
index 9629f94c75d..52477f68cd3 100644
--- a/clippy_lints/src/loops.rs
+++ b/clippy_lints/src/loops.rs
@@ -476,15 +476,21 @@ declare_lint_pass!(Loops => [
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Loops {
     #[allow(clippy::too_many_lines)]
     fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
+        if let Some((pat, arg, body)) = higher::for_loop(expr) {
+            // we don't want to check expanded macros
+            // this check is not at the top of the function
+            // since higher::for_loop expressions are marked as expansions
+            if body.span.from_expansion() {
+                return;
+            }
+            check_for_loop(cx, pat, arg, body, expr);
+        }
+
         // we don't want to check expanded macros
         if expr.span.from_expansion() {
             return;
         }
 
-        if let Some((pat, arg, body)) = higher::for_loop(expr) {
-            check_for_loop(cx, pat, arg, body, expr);
-        }
-
         // check for never_loop
         if let ExprKind::Loop(ref block, _, _) = expr.kind {
             match never_loop_block(block, expr.hir_id) {
@@ -1039,10 +1045,6 @@ fn check_for_loop_range<'a, 'tcx>(
     body: &'tcx Expr,
     expr: &'tcx Expr,
 ) {
-    if expr.span.from_expansion() {
-        return;
-    }
-
     if let Some(higher::Range {
         start: Some(start),
         ref end,