@@ -54,7 +54,7 @@ declare_lint_pass!(SuspiciousImpl => [SUSPICIOUS_ARITHMETIC_IMPL, SUSPICIOUS_OP_
5454
5555impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for SuspiciousImpl {
5656 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 {
5858 match binop. node {
5959 hir:: BinOpKind :: Eq
6060 | hir:: BinOpKind :: Lt
@@ -65,14 +65,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl {
6565 _ => { } ,
6666 }
6767 // 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
6969 let mut parent_expr = cx. tcx . hir ( ) . get_parent_node ( expr. hir_id ) ;
7070 while parent_expr != hir:: CRATE_HIR_ID {
7171 if let hir:: Node :: Expr ( e) = cx. tcx . hir ( ) . get ( parent_expr) {
7272 match e. kind {
7373 hir:: ExprKind :: Binary ( ..)
7474 | 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 ,
7677 _ => { } ,
7778 }
7879 }
@@ -191,7 +192,8 @@ impl<'a, 'tcx> Visitor<'tcx> for BinaryExprVisitor {
191192 match expr. kind {
192193 hir:: ExprKind :: Binary ( ..)
193194 | 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 ,
195197 _ => { } ,
196198 }
197199
0 commit comments