Skip to content

Commit aab4276

Browse files
Clean up E0164 explanation
1 parent ec64bbb commit aab4276

File tree

1 file changed

+29
-9
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+29
-9
lines changed
+29-9
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,44 @@
1-
This error means that an attempt was made to match a struct type enum
2-
variant as a non-struct type:
1+
Something which is neither a tuple struct nor a tuple variant was used as a
2+
pattern.
3+
4+
Erroneous code example:
35

46
```compile_fail,E0164
5-
enum Foo { B { i: u32 } }
7+
enum A {
8+
B,
9+
C,
10+
}
11+
12+
impl A {
13+
fn new() {}
14+
}
615
7-
fn bar(foo: Foo) -> u32 {
16+
fn bar(foo: A) {
817
match foo {
9-
Foo::B(i) => i, // error E0164
18+
A::new() => (), // error!
19+
_ => {}
1020
}
1121
}
1222
```
1323

14-
Try using `{}` instead:
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
26+
pattern:
1527

1628
```
17-
enum Foo { B { i: u32 } }
29+
enum A {
30+
B,
31+
C,
32+
}
33+
34+
impl A {
35+
fn new() {}
36+
}
1837
19-
fn bar(foo: Foo) -> u32 {
38+
fn bar(foo: A) {
2039
match foo {
21-
Foo::B{i} => i,
40+
A::B => (), // ok!
41+
_ => {}
2242
}
2343
}
2444
```

0 commit comments

Comments
 (0)