Debian Codegraph @

gcc/testsuite/rust/compile/exhaustiveness3.rs

raw
1 struct S {
2 e1: E1,
3 e2: E2,
4 }
5
6 enum E1 {
7 A(),
8 B(),
9 C(),
10 }
11
12 enum E2 {
13 D(),
14 E(),
15 }
16
17 // This is a valid match
18 fn f(s: S) {
19 match s {
20 S {
21 e1: E1::A(),
22 e2: E2::D(),
23 } => {}
24 S {
25 e1: E1::B(),
26 e2: E2::D(),
27 } => {}
28 S {
29 e1: E1::C(),
30 e2: E2::D(),
31 } => {}
32 S {
33 e1: E1::A(),
34 e2: E2::E(),
35 } => {}
36 S {
37 e1: E1::B(),
38 e2: E2::E(),
39 } => {}
40 S {
41 e1: E1::C(),
42 e2: E2::E(),
43 } => {}
44 }
45 }
46
47 fn f2(s: S) {
48 match s {
49 // { dg-error "non-exhaustive patterns: 'S { e1: E1::B.., e2: E2::D.. }' and 'S { e1: E1::C.., e2: E2::D.. }' not covered" "" { target *-*-* } .-1 }
50 S { e1: E1::A(), e2: _ } => {}
51 S { e1: _, e2: E2::E() } => {}
52 }
53 }
54
55 fn main() {}