1 #![warn(clippy::suspicious_arithmetic_impl)]
2 use std::ops::{Add, AddAssign, BitOrAssign, Div, DivAssign, Mul, MulAssign, Sub};
10 fn add(self, other: Self) -> Self {
15 impl AddAssign for Foo {
16 fn add_assign(&mut self, other: Foo) {
17 *self = *self - other;
21 impl BitOrAssign for Foo {
22 fn bitor_assign(&mut self, other: Foo) {
24 self.0 |= 1 << idx; // OK: BinOpKind::Shl part of AssignOp as child node
28 impl MulAssign for Foo {
29 fn mul_assign(&mut self, other: Foo) {
34 impl DivAssign for Foo {
35 fn div_assign(&mut self, other: Foo) {
36 self.0 /= other.0; // OK: BinOpKind::Div == DivAssign
43 fn mul(self, other: Foo) -> Foo {
44 Foo(self.0 * other.0 % 42) // OK: BinOpKind::Rem part of BiExpr as parent node
51 fn sub(self, other: Self) -> Self {
52 Foo(self.0 * other.0 - 42) // OK: BinOpKind::Mul part of BiExpr as child node
59 fn div(self, other: Self) -> Self {
60 Foo(do_nothing(self.0 + other.0) / 42) // OK: BinOpKind::Add part of BiExpr as child node
69 fn add(self, other: Self) -> Self {
70 Bar(self.0 & !other.0) // OK: UnNot part of BiExpr as child node
77 fn sub(self, other: Self) -> Self {
78 if self.0 <= other.0 {
79 Bar(-(self.0 & other.0)) // OK: UnNeg part of BiExpr as parent node
88 fn do_nothing(x: u32) -> u32 {