1 #![warn(clippy::suspicious_arithmetic_impl)]
2 use std::ops::{Add, AddAssign, Div, Mul, 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;
24 fn mul(self, other: Foo) -> Foo {
25 Foo(self.0 * other.0 % 42) // OK: BinOpKind::Rem part of BiExpr as parent node
32 fn sub(self, other: Self) -> Self {
33 Foo(self.0 * other.0 - 42) // OK: BinOpKind::Mul part of BiExpr as child node
40 fn div(self, other: Self) -> Self {
41 Foo(do_nothing(self.0 + other.0) / 42) // OK: BinOpKind::Add part of BiExpr as child node
50 fn add(self, other: Self) -> Self {
51 Bar(self.0 & !other.0) // OK: UnNot part of BiExpr as child node
58 fn sub(self, other: Self) -> Self {
59 if self.0 <= other.0 {
60 Bar(-(self.0 & other.0)) // OK: UnNeg part of BiExpr as parent node
69 fn do_nothing(x: u32) -> u32 {