@@ -54,7 +54,7 @@ declare_lint_pass!(SuspiciousImpl => [SUSPICIOUS_ARITHMETIC_IMPL, SUSPICIOUS_OP_
54
54
55
55
impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for SuspiciousImpl {
56
56
fn check_expr ( & mut self , cx : & LateContext < ' a , ' tcx > , expr : & ' tcx hir:: Expr < ' _ > ) {
57
- if let hir:: ExprKind :: Binary ( binop, _, _) = expr. kind {
57
+ if let hir:: ExprKind :: Binary ( binop, _, _) | hir :: ExprKind :: AssignOp ( binop , .. ) = expr. kind {
58
58
match binop. node {
59
59
hir:: BinOpKind :: Eq
60
60
| hir:: BinOpKind :: Lt
@@ -65,14 +65,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl {
65
65
_ => { } ,
66
66
}
67
67
// Check if the binary expression is part of another bi/unary expression
68
- // as a child node
68
+ // or operator assignment as a child node
69
69
let mut parent_expr = cx. tcx . hir ( ) . get_parent_node ( expr. hir_id ) ;
70
70
while parent_expr != hir:: CRATE_HIR_ID {
71
71
if let hir:: Node :: Expr ( e) = cx. tcx . hir ( ) . get ( parent_expr) {
72
72
match e. kind {
73
73
hir:: ExprKind :: Binary ( ..)
74
74
| hir:: ExprKind :: Unary ( hir:: UnOp :: UnNot , _)
75
- | hir:: ExprKind :: Unary ( hir:: UnOp :: UnNeg , _) => return ,
75
+ | hir:: ExprKind :: Unary ( hir:: UnOp :: UnNeg , _)
76
+ | hir:: ExprKind :: AssignOp ( ..) => return ,
76
77
_ => { } ,
77
78
}
78
79
}
@@ -191,7 +192,8 @@ impl<'a, 'tcx> Visitor<'tcx> for BinaryExprVisitor {
191
192
match expr. kind {
192
193
hir:: ExprKind :: Binary ( ..)
193
194
| hir:: ExprKind :: Unary ( hir:: UnOp :: UnNot , _)
194
- | hir:: ExprKind :: Unary ( hir:: UnOp :: UnNeg , _) => self . in_binary_expr = true ,
195
+ | hir:: ExprKind :: Unary ( hir:: UnOp :: UnNeg , _)
196
+ | hir:: ExprKind :: AssignOp ( ..) => self . in_binary_expr = true ,
195
197
_ => { } ,
196
198
}
197
199
0 commit comments