]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/const_in_pattern/no-eq-branch-fail.rs
New upstream version 1.46.0~beta.2+dfsg1
[rustc.git] / src / test / ui / consts / const_in_pattern / no-eq-branch-fail.rs
1 #![warn(indirect_structural_match)]
2
3 struct NoEq;
4
5 enum Foo {
6 Bar,
7 Baz,
8 Qux(NoEq),
9 }
10
11 // Even though any of these values can be compared structurally, we still disallow it in a pattern
12 // because `Foo` does not impl `PartialEq`.
13 const BAR_BAZ: Foo = if 42 == 42 {
14 Foo::Baz
15 } else {
16 Foo::Bar
17 };
18
19 fn main() {
20 match Foo::Qux(NoEq) {
21 BAR_BAZ => panic!(),
22 //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
23 //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
24 _ => {}
25 }
26 }