@@ -9,6 +9,7 @@ use rustc_middle::ty::{self, subst::GenericArgKind};
9
9
use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
10
10
use rustc_span:: sym;
11
11
use rustc_span:: symbol:: Ident ;
12
+ use std:: iter;
12
13
13
14
declare_clippy_lint ! {
14
15
/// **What it does:**
@@ -79,17 +80,15 @@ fn mirrored_exprs(
79
80
mirrored_exprs ( cx, left_expr, a_ident, right_expr, b_ident)
80
81
} ,
81
82
// 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
+ }
86
87
// The two exprs are function calls.
87
88
// Check to see that the function itself and its arguments are mirrored
88
89
( ExprKind :: Call ( left_expr, left_args) , ExprKind :: Call ( right_expr, right_args) ) => {
89
90
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)
93
92
. all ( |( left, right) | mirrored_exprs ( cx, left, a_ident, right, b_ident) )
94
93
} ,
95
94
// The two exprs are method calls.
@@ -100,16 +99,14 @@ fn mirrored_exprs(
100
99
ExprKind :: MethodCall ( right_segment, _, right_args, _) ,
101
100
) => {
102
101
left_segment. ident == right_segment. ident
103
- && left_args
104
- . iter ( )
105
- . zip ( right_args. iter ( ) )
102
+ && iter:: zip ( * left_args, * right_args)
106
103
. all ( |( left, right) | mirrored_exprs ( cx, left, a_ident, right, b_ident) )
107
- } ,
104
+ }
108
105
// 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
+ }
113
110
// Two binary ops, which are the same operation and which have mirrored arguments
114
111
( ExprKind :: Binary ( left_op, left_left, left_right) , ExprKind :: Binary ( right_op, right_left, right_right) ) => {
115
112
left_op. node == right_op. node
@@ -146,9 +143,7 @@ fn mirrored_exprs(
146
143
} ,
147
144
) ) ,
148
145
) => {
149
- ( left_segments
150
- . iter ( )
151
- . zip ( right_segments. iter ( ) )
146
+ ( iter:: zip ( * left_segments, * right_segments)
152
147
. all ( |( left, right) | left. ident == right. ident )
153
148
&& left_segments
154
149
. iter ( )
0 commit comments