@@ -9,6 +9,7 @@ use rustc_middle::ty::{self, subst::GenericArgKind};
99use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
1010use rustc_span:: sym;
1111use rustc_span:: symbol:: Ident ;
12+ use std:: iter;
1213
1314declare_clippy_lint ! {
1415 /// **What it does:**
@@ -79,17 +80,15 @@ fn mirrored_exprs(
7980 mirrored_exprs ( cx, left_expr, a_ident, right_expr, b_ident)
8081 } ,
8182 // Two arrays with mirrored contents
82- ( ExprKind :: Array ( left_exprs) , ExprKind :: Array ( right_exprs) ) => left_exprs
83- . iter ( )
84- . zip ( right_exprs . iter ( ) )
85- . all ( | ( left , right ) | mirrored_exprs ( cx , left , a_ident , right , b_ident ) ) ,
83+ ( ExprKind :: Array ( left_exprs) , ExprKind :: Array ( right_exprs) ) => {
84+ iter:: zip ( * left_exprs , * right_exprs )
85+ . all ( | ( left , right ) | mirrored_exprs ( cx , left , a_ident , right , b_ident ) )
86+ }
8687 // The two exprs are function calls.
8788 // Check to see that the function itself and its arguments are mirrored
8889 ( ExprKind :: Call ( left_expr, left_args) , ExprKind :: Call ( right_expr, right_args) ) => {
8990 mirrored_exprs ( cx, left_expr, a_ident, right_expr, b_ident)
90- && left_args
91- . iter ( )
92- . zip ( right_args. iter ( ) )
91+ && iter:: zip ( * left_args, * right_args)
9392 . all ( |( left, right) | mirrored_exprs ( cx, left, a_ident, right, b_ident) )
9493 } ,
9594 // The two exprs are method calls.
@@ -100,16 +99,14 @@ fn mirrored_exprs(
10099 ExprKind :: MethodCall ( right_segment, _, right_args, _) ,
101100 ) => {
102101 left_segment. ident == right_segment. ident
103- && left_args
104- . iter ( )
105- . zip ( right_args. iter ( ) )
102+ && iter:: zip ( * left_args, * right_args)
106103 . all ( |( left, right) | mirrored_exprs ( cx, left, a_ident, right, b_ident) )
107- } ,
104+ }
108105 // Two tuples with mirrored contents
109- ( ExprKind :: Tup ( left_exprs) , ExprKind :: Tup ( right_exprs) ) => left_exprs
110- . iter ( )
111- . zip ( right_exprs . iter ( ) )
112- . all ( | ( left , right ) | mirrored_exprs ( cx , left , a_ident , right , b_ident ) ) ,
106+ ( ExprKind :: Tup ( left_exprs) , ExprKind :: Tup ( right_exprs) ) => {
107+ iter:: zip ( * left_exprs , * right_exprs )
108+ . all ( | ( left , right ) | mirrored_exprs ( cx , left , a_ident , right , b_ident ) )
109+ }
113110 // Two binary ops, which are the same operation and which have mirrored arguments
114111 ( ExprKind :: Binary ( left_op, left_left, left_right) , ExprKind :: Binary ( right_op, right_left, right_right) ) => {
115112 left_op. node == right_op. node
@@ -146,9 +143,7 @@ fn mirrored_exprs(
146143 } ,
147144 ) ) ,
148145 ) => {
149- ( left_segments
150- . iter ( )
151- . zip ( right_segments. iter ( ) )
146+ ( iter:: zip ( * left_segments, * right_segments)
152147 . all ( |( left, right) | left. ident == right. ident )
153148 && left_segments
154149 . iter ( )
0 commit comments