]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const_in_pattern/reject_non_partial_eq.rs
Rollup merge of #98609 - TaKO8Ki:fix-ice-for-associated-constant-generics, r=lcnr
[rust.git] / src / test / ui / consts / const_in_pattern / reject_non_partial_eq.rs
1 // This test is illustrating the difference between how failing to derive
2 // `PartialEq` is handled compared to failing to implement it at all.
3
4 // See also RFC 1445
5
6 #[derive(PartialEq, Eq)]
7 struct Structural(u32);
8
9 struct NoPartialEq(u32);
10
11 struct NoDerive(u32);
12
13 // This impl makes NoDerive irreflexive.
14 impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
15
16 impl Eq for NoDerive { }
17
18 const NO_DERIVE_NONE: Option<NoDerive> = None;
19 const NO_PARTIAL_EQ_NONE: Option<NoPartialEq> = None;
20
21 fn main() {
22     match None {
23         NO_DERIVE_NONE => println!("NO_DERIVE_NONE"),
24         _ => panic!("whoops"),
25     }
26
27     match None {
28         NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"),
29         //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
30         _ => panic!("whoops"),
31     }
32 }