Clean up E0164 explanation

This commit is contained in:
Guillaume Gomez 2020-01-03 17:42:56 +01:00
parent ec64bbbe07
commit aab4276477

View file

@ -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,
}
fn bar(foo: Foo) -> u32 {
impl A {
fn new() {}
}
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,
}
fn bar(foo: Foo) -> u32 {
impl A {
fn new() {}
}
fn bar(foo: A) {
match foo {
Foo::B{i} => i,
A::B => (), // ok!
_ => {}
}
}
```