@@ -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,14 @@ 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) . all ( |( left, right) | mirrored_exprs ( cx, left, a_ident, right, b_ident) )
85
+ } ,
86
86
// The two exprs are function calls.
87
87
// Check to see that the function itself and its arguments are mirrored
88
88
( ExprKind :: Call ( left_expr, left_args) , ExprKind :: Call ( right_expr, right_args) ) => {
89
89
mirrored_exprs ( cx, left_expr, a_ident, right_expr, b_ident)
90
- && left_args
91
- . iter ( )
92
- . zip ( right_args. iter ( ) )
90
+ && iter:: zip ( * left_args, * right_args)
93
91
. all ( |( left, right) | mirrored_exprs ( cx, left, a_ident, right, b_ident) )
94
92
} ,
95
93
// The two exprs are method calls.
@@ -100,16 +98,13 @@ fn mirrored_exprs(
100
98
ExprKind :: MethodCall ( right_segment, _, right_args, _) ,
101
99
) => {
102
100
left_segment. ident == right_segment. ident
103
- && left_args
104
- . iter ( )
105
- . zip ( right_args. iter ( ) )
101
+ && iter:: zip ( * left_args, * right_args)
106
102
. all ( |( left, right) | mirrored_exprs ( cx, left, a_ident, right, b_ident) )
107
103
} ,
108
104
// 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) ) ,
105
+ ( ExprKind :: Tup ( left_exprs) , ExprKind :: Tup ( right_exprs) ) => {
106
+ iter:: zip ( * left_exprs, * right_exprs) . all ( |( left, right) | mirrored_exprs ( cx, left, a_ident, right, b_ident) )
107
+ } ,
113
108
// Two binary ops, which are the same operation and which have mirrored arguments
114
109
( ExprKind :: Binary ( left_op, left_left, left_right) , ExprKind :: Binary ( right_op, right_left, right_right) ) => {
115
110
left_op. node == right_op. node
@@ -146,10 +141,7 @@ fn mirrored_exprs(
146
141
} ,
147
142
) ) ,
148
143
) => {
149
- ( left_segments
150
- . iter ( )
151
- . zip ( right_segments. iter ( ) )
152
- . all ( |( left, right) | left. ident == right. ident )
144
+ ( iter:: zip ( * left_segments, * right_segments) . all ( |( left, right) | left. ident == right. ident )
153
145
&& left_segments
154
146
. iter ( )
155
147
. all ( |seg| & seg. ident != a_ident && & seg. ident != b_ident) )
0 commit comments