@@ -42,16 +42,15 @@ pub(crate) fn check<'tcx>(
4242
4343 match op {
4444 BinOpKind :: Add | BinOpKind :: BitOr | BinOpKind :: BitXor => {
45- check_op (
45+ let _ = check_op (
4646 cx,
4747 left,
4848 0 ,
4949 expr. span ,
5050 peeled_right_span,
5151 needs_parenthesis ( cx, expr, right) ,
5252 right_is_coerced_to_value,
53- ) ;
54- check_op (
53+ ) || check_op (
5554 cx,
5655 right,
5756 0 ,
@@ -62,7 +61,7 @@ pub(crate) fn check<'tcx>(
6261 ) ;
6362 } ,
6463 BinOpKind :: Shl | BinOpKind :: Shr | BinOpKind :: Sub => {
65- check_op (
64+ let _ = check_op (
6665 cx,
6766 right,
6867 0 ,
@@ -73,16 +72,26 @@ pub(crate) fn check<'tcx>(
7372 ) ;
7473 } ,
7574 BinOpKind :: Mul => {
76- check_op (
75+ let _ = check_op (
7776 cx,
7877 left,
7978 1 ,
8079 expr. span ,
8180 peeled_right_span,
8281 needs_parenthesis ( cx, expr, right) ,
8382 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,
8491 ) ;
85- check_op (
92+ } ,
93+ BinOpKind :: Div => {
94+ let _ = check_op (
8695 cx,
8796 right,
8897 1 ,
@@ -92,26 +101,16 @@ pub(crate) fn check<'tcx>(
92101 left_is_coerced_to_value,
93102 ) ;
94103 } ,
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- ) ,
104104 BinOpKind :: BitAnd => {
105- check_op (
105+ let _ = check_op (
106106 cx,
107107 left,
108108 -1 ,
109109 expr. span ,
110110 peeled_right_span,
111111 needs_parenthesis ( cx, expr, right) ,
112112 right_is_coerced_to_value,
113- ) ;
114- check_op (
113+ ) || check_op (
115114 cx,
116115 right,
117116 -1 ,
@@ -201,12 +200,12 @@ fn check_remainder(cx: &LateContext<'_>, left: &Expr<'_>, right: &Expr<'_>, span
201200 }
202201}
203202
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 {
205204 if let Some ( Constant :: Int ( v) ) = constant_simple ( cx, cx. typeck_results ( ) , e) . map ( Constant :: peel_refs) {
206205 let check = match * cx. typeck_results ( ) . expr_ty ( e) . peel_refs ( ) . kind ( ) {
207206 ty:: Int ( ity) => unsext ( cx. tcx , -1_i128 , ity) ,
208207 ty:: Uint ( uty) => clip ( cx. tcx , !0 , uty) ,
209- _ => return ,
208+ _ => return false ,
210209 } ;
211210 if match m {
212211 0 => v == 0 ,
@@ -215,8 +214,10 @@ fn check_op(cx: &LateContext<'_>, e: &Expr<'_>, m: i8, span: Span, arg: Span, pa
215214 _ => unreachable ! ( ) ,
216215 } {
217216 span_ineffective_operation ( cx, span, arg, parens, is_erased) ;
217+ return true ;
218218 }
219219 }
220+ false
220221}
221222
222223fn span_ineffective_operation (
0 commit comments