about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRyan1729 <Ryan1729@gmail.com>2020-08-12 09:17:40 -0600
committerRyan1729 <Ryan1729@gmail.com>2020-08-12 10:33:16 -0600
commitf4eeff99b6f2d5a01f7af1eae46e1b84525bf95a (patch)
treef342d3bae8e954915d8cfc5ae19b45cbbf46a820
parentc70581732de89a1b4f064818edeca9a18913ded2 (diff)
downloadrust-f4eeff99b6f2d5a01f7af1eae46e1b84525bf95a.tar.gz
rust-f4eeff99b6f2d5a01f7af1eae46e1b84525bf95a.zip
add tests for Rem, BitAnd, BitOr, BitXor, Shl, and Shr
-rw-r--r--tests/ui/suspicious_arithmetic_impl.rs52
1 files changed, 51 insertions, 1 deletions
diff --git a/tests/ui/suspicious_arithmetic_impl.rs b/tests/ui/suspicious_arithmetic_impl.rs
index 60c2f3ec9b6..5c280efac1a 100644
--- a/tests/ui/suspicious_arithmetic_impl.rs
+++ b/tests/ui/suspicious_arithmetic_impl.rs
@@ -1,5 +1,7 @@
 #![warn(clippy::suspicious_arithmetic_impl)]
-use std::ops::{Add, AddAssign, BitOrAssign, Div, DivAssign, Mul, MulAssign, Sub};
+use std::ops::{
+    Add, AddAssign, BitAnd, BitOr, BitOrAssign, BitXor, Div, DivAssign, Mul, MulAssign, Rem, Shl, Shr, Sub,
+};
 
 #[derive(Copy, Clone)]
 struct Foo(u32);
@@ -61,6 +63,54 @@ impl Div for Foo {
     }
 }
 
+impl Rem for Foo {
+    type Output = Foo;
+
+    fn rem(self, other: Self) -> Self {
+        Foo(self.0 / other.0)
+    }
+}
+
+impl BitAnd for Foo {
+    type Output = Foo;
+
+    fn bitand(self, other: Self) -> Self {
+        Foo(self.0 | other.0)
+    }
+}
+
+impl BitOr for Foo {
+    type Output = Foo;
+
+    fn bitor(self, other: Self) -> Self {
+        Foo(self.0 ^ other.0)
+    }
+}
+
+impl BitXor for Foo {
+    type Output = Foo;
+
+    fn bitxor(self, other: Self) -> Self {
+        Foo(self.0 & other.0)
+    }
+}
+
+impl Shl for Foo {
+    type Output = Foo;
+
+    fn shl(self, other: Self) -> Self {
+        Foo(self.0 >> other.0)
+    }
+}
+
+impl Shr for Foo {
+    type Output = Foo;
+
+    fn shr(self, other: Self) -> Self {
+        Foo(self.0 << other.0)
+    }
+}
+
 struct Bar(i32);
 
 impl Add for Bar {