@@ -42,16 +42,15 @@ pub(crate) fn check<'tcx>(
42
42
43
43
match op {
44
44
BinOpKind :: Add | BinOpKind :: BitOr | BinOpKind :: BitXor => {
45
- check_op (
45
+ let _ = check_op (
46
46
cx,
47
47
left,
48
48
0 ,
49
49
expr. span ,
50
50
peeled_right_span,
51
51
needs_parenthesis ( cx, expr, right) ,
52
52
right_is_coerced_to_value,
53
- ) ;
54
- check_op (
53
+ ) || check_op (
55
54
cx,
56
55
right,
57
56
0 ,
@@ -62,7 +61,7 @@ pub(crate) fn check<'tcx>(
62
61
) ;
63
62
} ,
64
63
BinOpKind :: Shl | BinOpKind :: Shr | BinOpKind :: Sub => {
65
- check_op (
64
+ let _ = check_op (
66
65
cx,
67
66
right,
68
67
0 ,
@@ -73,16 +72,26 @@ pub(crate) fn check<'tcx>(
73
72
) ;
74
73
} ,
75
74
BinOpKind :: Mul => {
76
- check_op (
75
+ let _ = check_op (
77
76
cx,
78
77
left,
79
78
1 ,
80
79
expr. span ,
81
80
peeled_right_span,
82
81
needs_parenthesis ( cx, expr, right) ,
83
82
right_is_coerced_to_value,
83
+ ) || check_op (
84
+ cx,
85
+ right,
86
+ 1 ,
87
+ expr. span ,
88
+ peeled_left_span,
89
+ Parens :: Unneeded ,
90
+ left_is_coerced_to_value,
84
91
) ;
85
- check_op (
92
+ } ,
93
+ BinOpKind :: Div => {
94
+ let _ = check_op (
86
95
cx,
87
96
right,
88
97
1 ,
@@ -92,26 +101,16 @@ pub(crate) fn check<'tcx>(
92
101
left_is_coerced_to_value,
93
102
) ;
94
103
} ,
95
- BinOpKind :: Div => check_op (
96
- cx,
97
- right,
98
- 1 ,
99
- expr. span ,
100
- peeled_left_span,
101
- Parens :: Unneeded ,
102
- left_is_coerced_to_value,
103
- ) ,
104
104
BinOpKind :: BitAnd => {
105
- check_op (
105
+ let _ = check_op (
106
106
cx,
107
107
left,
108
108
-1 ,
109
109
expr. span ,
110
110
peeled_right_span,
111
111
needs_parenthesis ( cx, expr, right) ,
112
112
right_is_coerced_to_value,
113
- ) ;
114
- check_op (
113
+ ) || check_op (
115
114
cx,
116
115
right,
117
116
-1 ,
@@ -201,12 +200,12 @@ fn check_remainder(cx: &LateContext<'_>, left: &Expr<'_>, right: &Expr<'_>, span
201
200
}
202
201
}
203
202
204
- fn check_op ( cx : & LateContext < ' _ > , e : & Expr < ' _ > , m : i8 , span : Span , arg : Span , parens : Parens , is_erased : bool ) {
203
+ fn check_op ( cx : & LateContext < ' _ > , e : & Expr < ' _ > , m : i8 , span : Span , arg : Span , parens : Parens , is_erased : bool ) -> bool {
205
204
if let Some ( Constant :: Int ( v) ) = constant_simple ( cx, cx. typeck_results ( ) , e) . map ( Constant :: peel_refs) {
206
205
let check = match * cx. typeck_results ( ) . expr_ty ( e) . peel_refs ( ) . kind ( ) {
207
206
ty:: Int ( ity) => unsext ( cx. tcx , -1_i128 , ity) ,
208
207
ty:: Uint ( uty) => clip ( cx. tcx , !0 , uty) ,
209
- _ => return ,
208
+ _ => return false ,
210
209
} ;
211
210
if match m {
212
211
0 => v == 0 ,
@@ -215,8 +214,10 @@ fn check_op(cx: &LateContext<'_>, e: &Expr<'_>, m: i8, span: Span, arg: Span, pa
215
214
_ => unreachable ! ( ) ,
216
215
} {
217
216
span_ineffective_operation ( cx, span, arg, parens, is_erased) ;
217
+ return true ;
218
218
}
219
219
}
220
+ false
220
221
}
221
222
222
223
fn span_ineffective_operation (
0 commit comments