2018-07-28 15:34:52 +00:00
|
|
|
#![allow(unused_variables, clippy::blacklisted_name)]
|
2019-09-20 05:54:16 +00:00
|
|
|
#![warn(clippy::op_ref)]
|
2017-04-10 13:10:19 +00:00
|
|
|
use std::collections::HashSet;
|
2022-01-16 17:17:22 +00:00
|
|
|
use std::ops::{BitAnd, Mul};
|
2017-04-10 13:10:19 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let tracked_fds: HashSet<i32> = HashSet::new();
|
|
|
|
let new_fds = HashSet::new();
|
|
|
|
let unwanted = &tracked_fds - &new_fds;
|
2018-10-11 10:16:22 +00:00
|
|
|
|
2017-04-10 13:10:19 +00:00
|
|
|
let foo = &5 - &6;
|
|
|
|
|
|
|
|
let bar = String::new();
|
|
|
|
let bar = "foo" == &bar;
|
|
|
|
|
|
|
|
let a = "a".to_string();
|
|
|
|
let b = "a";
|
|
|
|
|
|
|
|
if b < &a {
|
|
|
|
println!("OK");
|
|
|
|
}
|
2019-09-20 05:54:16 +00:00
|
|
|
|
|
|
|
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;
|
2017-09-18 10:47:33 +00:00
|
|
|
}
|
2022-01-16 17:17:22 +00:00
|
|
|
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
struct A(i32);
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
struct B(i32);
|
|
|
|
|
|
|
|
impl Mul<&A> for B {
|
|
|
|
type Output = i32;
|
|
|
|
fn mul(self, rhs: &A) -> Self::Output {
|
|
|
|
self.0 * rhs.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl Mul<A> for B {
|
|
|
|
type Output = i32;
|
|
|
|
fn mul(self, rhs: A) -> Self::Output {
|
|
|
|
// Should not lint because removing the reference would lead to unconditional recursion
|
|
|
|
self * &rhs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl Mul<&A> for A {
|
|
|
|
type Output = i32;
|
|
|
|
fn mul(self, rhs: &A) -> Self::Output {
|
|
|
|
self.0 * rhs.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl Mul<A> for A {
|
|
|
|
type Output = i32;
|
|
|
|
fn mul(self, rhs: A) -> Self::Output {
|
|
|
|
let one = B(1);
|
|
|
|
let two = 2;
|
|
|
|
let three = 3;
|
|
|
|
let _ = one * &self;
|
|
|
|
let _ = two + &three;
|
|
|
|
// Removing the reference would lead to unconditional recursion
|
|
|
|
self * &rhs
|
|
|
|
}
|
|
|
|
}
|