]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/const_in_pattern/custom-eq-branch-warn.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / consts / const_in_pattern / custom-eq-branch-warn.rs
1 // check-pass
2
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
32 //~| NOTE see issue #73448
33 //~| NOTE `#[warn(nontrivial_structural_match)]` on by default
34 _ => {}
35 }
36 }