summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/derive_hash_xor_eq.rs
blob: 813ddc5664642733f1a786a8a0bde0497dd19573 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#![allow(clippy::derive_partial_eq_without_eq)]

#[derive(PartialEq, Hash)]
struct Foo;

impl PartialEq<u64> for Foo {
    fn eq(&self, _: &u64) -> bool {
        true
    }
}

#[derive(Hash)]
struct Bar;

impl PartialEq for Bar {
    fn eq(&self, _: &Bar) -> bool {
        true
    }
}

#[derive(Hash)]
struct Baz;

impl PartialEq<Baz> for Baz {
    fn eq(&self, _: &Baz) -> bool {
        true
    }
}

#[derive(PartialEq)]
struct Bah;

impl std::hash::Hash for Bah {
    fn hash<H: std::hash::Hasher>(&self, _: &mut H) {}
}

#[derive(PartialEq)]
struct Foo2;

trait Hash {}

// We don't want to lint on user-defined traits called `Hash`
impl Hash for Foo2 {}

mod use_hash {
    use std::hash::{Hash, Hasher};

    #[derive(PartialEq)]
    struct Foo3;

    impl Hash for Foo3 {
        fn hash<H: std::hash::Hasher>(&self, _: &mut H) {}
    }
}

fn main() {}