]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const_in_pattern/no-eq-branch-fail.rs
Merge commit 'd0cf3481a84e3aa68c2f185c460e282af36ebc42' into clippyup
[rust.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         _ => {}
24     }
25 }