]>
Commit | Line | Data |
---|---|---|
f9f354fc XL |
1 | // check-pass |
2 | ||
f9f354fc XL |
3 | struct CustomEq; |
4 | ||
5 | impl Eq for CustomEq {} | |
6 | impl PartialEq for CustomEq { | |
7 | fn eq(&self, _: &Self) -> bool { | |
8 | false | |
9 | } | |
10 | } | |
11 | ||
12 | #[derive(PartialEq, Eq)] | |
13 | enum Foo { | |
14 | Bar, | |
15 | Baz, | |
16 | Qux(CustomEq), | |
17 | } | |
18 | ||
19 | // We know that `BAR_BAZ` will always be `Foo::Bar` and thus eligible for structural matching, but | |
20 | // dataflow will be more conservative. | |
21 | const BAR_BAZ: Foo = if 42 == 42 { | |
22 | Foo::Bar | |
23 | } else { | |
24 | Foo::Qux(CustomEq) | |
25 | }; | |
26 | ||
27 | fn main() { | |
28 | match Foo::Qux(CustomEq) { | |
29 | BAR_BAZ => panic!(), | |
30 | //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]` | |
31 | //~| WARN this was previously accepted | |
1b1a35ee XL |
32 | //~| NOTE see issue #73448 |
33 | //~| NOTE `#[warn(nontrivial_structural_match)]` on by default | |
f9f354fc XL |
34 | _ => {} |
35 | } | |
36 | } |