@@ -476,15 +476,21 @@ declare_lint_pass!(Loops => [
476476impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for Loops {
477477 #[ allow( clippy:: too_many_lines) ]
478478 fn check_expr ( & mut self , cx : & LateContext < ' a , ' tcx > , expr : & ' tcx Expr ) {
479+ if let Some ( ( pat, arg, body) ) = higher:: for_loop ( expr) {
480+ // we don't want to check expanded macros
481+ // this check is not at the top of the function
482+ // since higher::for_loop expressions are marked as expansions
483+ if body. span . from_expansion ( ) {
484+ return ;
485+ }
486+ check_for_loop ( cx, pat, arg, body, expr) ;
487+ }
488+
479489 // we don't want to check expanded macros
480490 if expr. span . from_expansion ( ) {
481491 return ;
482492 }
483493
484- if let Some ( ( pat, arg, body) ) = higher:: for_loop ( expr) {
485- check_for_loop ( cx, pat, arg, body, expr) ;
486- }
487-
488494 // check for never_loop
489495 if let ExprKind :: Loop ( ref block, _, _) = expr. kind {
490496 match never_loop_block ( block, expr. hir_id ) {
@@ -1039,10 +1045,6 @@ fn check_for_loop_range<'a, 'tcx>(
10391045 body : & ' tcx Expr ,
10401046 expr : & ' tcx Expr ,
10411047) {
1042- if expr. span . from_expansion ( ) {
1043- return ;
1044- }
1045-
10461048 if let Some ( higher:: Range {
10471049 start : Some ( start) ,
10481050 ref end,
0 commit comments