]> git.proxmox.com Git - rustc.git/blame - src/test/ui/consts/const_in_pattern/custom-eq-branch-warn.rs
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / src / test / ui / consts / const_in_pattern / custom-eq-branch-warn.rs
CommitLineData
f9f354fc
XL
1// check-pass
2
f9f354fc
XL
3struct CustomEq;
4
5impl Eq for CustomEq {}
6impl PartialEq for CustomEq {
7 fn eq(&self, _: &Self) -> bool {
8 false
9 }
10}
11
12#[derive(PartialEq, Eq)]
13enum 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.
21const BAR_BAZ: Foo = if 42 == 42 {
22 Foo::Bar
23} else {
24 Foo::Qux(CustomEq)
25};
26
27fn 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}