@@ -476,15 +476,21 @@ declare_lint_pass!(Loops => [
476
476
impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for Loops {
477
477
#[ allow( clippy:: too_many_lines) ]
478
478
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
+
479
489
// we don't want to check expanded macros
480
490
if expr. span . from_expansion ( ) {
481
491
return ;
482
492
}
483
493
484
- if let Some ( ( pat, arg, body) ) = higher:: for_loop ( expr) {
485
- check_for_loop ( cx, pat, arg, body, expr) ;
486
- }
487
-
488
494
// check for never_loop
489
495
if let ExprKind :: Loop ( ref block, _, _) = expr. kind {
490
496
match never_loop_block ( block, expr. hir_id ) {
@@ -1039,10 +1045,6 @@ fn check_for_loop_range<'a, 'tcx>(
1039
1045
body : & ' tcx Expr ,
1040
1046
expr : & ' tcx Expr ,
1041
1047
) {
1042
- if expr. span . from_expansion ( ) {
1043
- return ;
1044
- }
1045
-
1046
1048
if let Some ( higher:: Range {
1047
1049
start : Some ( start) ,
1048
1050
ref end,
0 commit comments