Skip to content

Commit d1dbf79

Browse files
committed
Expresions with Assign / AssignOp have side effects
1 parent 9b800b1 commit d1dbf79

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clippy_lints/src/utils/hir_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
8989
both(&li.label, &ri.label, |l, r| l.ident.as_str() == r.ident.as_str())
9090
},
9191
(&ExprKind::Assign(ref ll, ref lr, _), &ExprKind::Assign(ref rl, ref rr, _)) => {
92-
self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
92+
self.allow_side_effects && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
9393
},
9494
(&ExprKind::AssignOp(ref lo, ref ll, ref lr), &ExprKind::AssignOp(ref ro, ref rl, ref rr)) => {
95-
lo.node == ro.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
95+
self.allow_side_effects && lo.node == ro.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
9696
},
9797
(&ExprKind::Block(ref l, _), &ExprKind::Block(ref r, _)) => self.eq_block(l, r),
9898
(&ExprKind::Binary(l_op, ref ll, ref lr), &ExprKind::Binary(r_op, ref rl, ref rr)) => {

0 commit comments

Comments
 (0)