]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0164.md
Merge commit 'f2cdd4a78d89c009342197cf5844a21f8aa813df' into sync_cg_clif-2022-04-22
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0164.md
1 Something which is neither a tuple struct nor a tuple variant was used as a
2 pattern.
3
4 Erroneous code example:
5
6 ```compile_fail,E0164
7 enum A {
8     B,
9     C,
10 }
11
12 impl A {
13     fn new() {}
14 }
15
16 fn bar(foo: A) {
17     match foo {
18         A::new() => (), // error!
19         _ => {}
20     }
21 }
22 ```
23
24 This error means that an attempt was made to match something which is neither a
25 tuple struct nor a tuple variant. Only these two elements are allowed as a
26 pattern:
27
28 ```
29 enum A {
30     B,
31     C,
32 }
33
34 impl A {
35     fn new() {}
36 }
37
38 fn bar(foo: A) {
39     match foo {
40         A::B => (), // ok!
41         _ => {}
42     }
43 }
44 ```