Skip to content
Permalink
Browse files

Clean up E0164 explanation

  • Loading branch information
GuillaumeGomez committed Jan 3, 2020
1 parent ec64bbb commit aab4276477e84545641b1cf69b43612efa6bf702
Showing with 29 additions and 9 deletions.
  1. +29 −9 src/librustc_error_codes/error_codes/E0164.md
@@ -1,24 +1,44 @@
This error means that an attempt was made to match a struct type enum
variant as a non-struct type:
Something which is neither a tuple struct nor a tuple variant was used as a
pattern.

Erroneous code example:

```compile_fail,E0164
enum Foo { B { i: u32 } }
enum A {
B,
C,
}
impl A {
fn new() {}
}
fn bar(foo: Foo) -> u32 {
fn bar(foo: A) {
match foo {
Foo::B(i) => i, // error E0164
A::new() => (), // error!
_ => {}
}
}
```

Try using `{}` instead:
This error means that an attempt was made to match something which is neither a
tuple struct nor a tuple variant. Only these two elements are allowed as
pattern:

```
enum Foo { B { i: u32 } }
enum A {
B,
C,
}
impl A {
fn new() {}
}
fn bar(foo: Foo) -> u32 {
fn bar(foo: A) {
match foo {
Foo::B{i} => i,
A::B => (), // ok!
_ => {}
}
}
```

0 comments on commit aab4276

Please sign in to comment.
You can’t perform that action at this time.