]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/clippy_lints/src/loops/mod.rs
Merge commit '98e2b9f25b6db4b2680a3d388456d9f95cb28344' into clippyup
[rust.git] / src / tools / clippy / clippy_lints / src / loops / mod.rs
index 28acefd51fef74554630f7bea55ae5469c18b2cb..a4bc3e6bd100cd4c47c9b31febd8144209b183a2 100644 (file)
@@ -602,22 +602,19 @@ fn check_for_loop<'tcx>(
 fn check_for_loop_arg(cx: &LateContext<'_>, pat: &Pat<'_>, arg: &Expr<'_>, expr: &Expr<'_>) {
     let mut next_loop_linted = false; // whether or not ITER_NEXT_LOOP lint was used
 
-    if let ExprKind::MethodCall(method, _, args, _) = arg.kind {
-        // just the receiver, no arguments
-        if args.len() == 1 {
-            let method_name = &*method.ident.as_str();
-            // check for looping over x.iter() or x.iter_mut(), could use &x or &mut x
-            match method_name {
-                "iter" | "iter_mut" => explicit_iter_loop::check(cx, args, arg, method_name),
-                "into_iter" => {
-                    explicit_iter_loop::check(cx, args, arg, method_name);
-                    explicit_into_iter_loop::check(cx, args, arg);
-                },
-                "next" => {
-                    next_loop_linted = iter_next_loop::check(cx, arg, expr);
-                },
-                _ => {},
-            }
+    if let ExprKind::MethodCall(method, _, [self_arg], _) = arg.kind {
+        let method_name = &*method.ident.as_str();
+        // check for looping over x.iter() or x.iter_mut(), could use &x or &mut x
+        match method_name {
+            "iter" | "iter_mut" => explicit_iter_loop::check(cx, self_arg, arg, method_name),
+            "into_iter" => {
+                explicit_iter_loop::check(cx, self_arg, arg, method_name);
+                explicit_into_iter_loop::check(cx, self_arg, arg);
+            },
+            "next" => {
+                next_loop_linted = iter_next_loop::check(cx, arg, expr);
+            },
+            _ => {},
         }
     }