diff --git a/tests/ui/eq_op.rs b/tests/ui/eq_op.rs index 842e5729fcd..cbe12b066c9 100644 --- a/tests/ui/eq_op.rs +++ b/tests/ui/eq_op.rs @@ -2,7 +2,7 @@ #![plugin(clippy)] #[deny(eq_op)] -#[allow(identity_op, double_parens)] +#[allow(identity_op, double_parens, many_single_char_names)] #[allow(no_effect, unused_variables, unnecessary_operation, short_circuit_statement)] #[deny(nonminimal_bool)] fn main() { @@ -59,4 +59,40 @@ fn main() { a == a; 2*a.len() == 2*a.len(); // ok, functions a.pop() == a.pop(); // ok, functions + + use std::ops::BitAnd; + struct X(i32); + impl BitAnd for X { + type Output = X; + fn bitand(self, rhs: X) -> X { + X(self.0 & rhs.0) + } + } + impl<'a> BitAnd<&'a X> for X { + type Output = X; + fn bitand(self, rhs: &'a X) -> X { + X(self.0 & rhs.0) + } + } + let x = X(1); + let y = X(2); + let z = x & &y; + + #[derive(Copy, Clone)] + struct Y(i32); + impl BitAnd for Y { + type Output = Y; + fn bitand(self, rhs: Y) -> Y { + Y(self.0 & rhs.0) + } + } + impl<'a> BitAnd<&'a Y> for Y { + type Output = Y; + fn bitand(self, rhs: &'a Y) -> Y { + Y(self.0 & rhs.0) + } + } + let x = Y(1); + let y = Y(2); + let z = x & &y; } diff --git a/tests/ui/eq_op.stderr b/tests/ui/eq_op.stderr index dc2df524df2..b4ece862e00 100644 --- a/tests/ui/eq_op.stderr +++ b/tests/ui/eq_op.stderr @@ -219,5 +219,15 @@ error: equal expressions as operands to `==` 59 | a == a; | ^^^^^^ +warning: taken reference of right operand + --> $DIR/eq_op.rs:97:13 + | +97 | let z = x & &y; + | ^^^^^^ + | + = note: #[warn(op_ref)] on by default +help: use the right value directly + | let z = y & &y; + error: aborting due to 32 previous errors