Skip to content

Commit

Permalink
Incorrect suspicious_op_assign_impl
Browse files Browse the repository at this point in the history
  • Loading branch information
jpospychala committed Apr 5, 2020
1 parent 7907abe commit 762f5d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion clippy_lints/src/suspicious_trait_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl {
match e.kind {
hir::ExprKind::Binary(..)
| hir::ExprKind::Unary(hir::UnOp::UnNot, _)
| hir::ExprKind::Unary(hir::UnOp::UnNeg, _) => return,
| hir::ExprKind::Unary(hir::UnOp::UnNeg, _)
| hir::ExprKind::AssignOp(..) => return,
_ => {},
}
}
Expand Down
9 changes: 8 additions & 1 deletion tests/ui/suspicious_arithmetic_impl.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(clippy::suspicious_arithmetic_impl)]
use std::ops::{Add, AddAssign, Div, Mul, Sub};
use std::ops::{Add, AddAssign, BitOrAssign, Div, Mul, Sub};

#[derive(Copy, Clone)]
struct Foo(u32);
Expand All @@ -18,6 +18,13 @@ impl AddAssign for Foo {
}
}

impl BitOrAssign for Foo {
fn bitor_assign(&mut self, other: Foo) {
let idx = other.0;
self.0 |= 1 << idx;
}
}

impl Mul for Foo {
type Output = Foo;

Expand Down

0 comments on commit 762f5d3

Please sign in to comment.