diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-01-03 17:42:56 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-01-04 00:32:29 +0100 |
| commit | aab4276477e84545641b1cf69b43612efa6bf702 (patch) | |
| tree | 3268343e9f3c70c10882eb3b7783be80ae49743c /src/librustc_error_codes/error_codes | |
| parent | ec64bbbe07df8e502b64e449be86c1613717c0c7 (diff) | |
| download | rust-aab4276477e84545641b1cf69b43612efa6bf702.tar.gz rust-aab4276477e84545641b1cf69b43612efa6bf702.zip | |
Clean up E0164 explanation
Diffstat (limited to 'src/librustc_error_codes/error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0164.md | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/librustc_error_codes/error_codes/E0164.md b/src/librustc_error_codes/error_codes/E0164.md index b41ce6fad8e..8eb5ace4fe4 100644 --- a/src/librustc_error_codes/error_codes/E0164.md +++ b/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! + _ => {} } } ``` |
