Skip to content

Commit

Permalink
add tests for Rem, BitAnd, BitOr, BitXor, Shl, and Shr
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan1729 committed Aug 12, 2020
1 parent c705817 commit f4eeff9
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion tests/ui/suspicious_arithmetic_impl.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f4eeff9

Please sign in to comment.