diff options
| author | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-03-23 22:54:02 +0900 |
|---|---|---|
| committer | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-03-23 22:54:02 +0900 |
| commit | 925857d8dcd88e243125bf8a7467c9f055ae958e (patch) | |
| tree | 966771b040e6869c2314235b75cf6a398bb515c6 /src | |
| parent | 3ea44938e21f0de8ae7d4f6399a8a30f97867c70 (diff) | |
| download | rust-925857d8dcd88e243125bf8a7467c9f055ae958e.tar.gz rust-925857d8dcd88e243125bf8a7467c9f055ae958e.zip | |
stop emitting E0026 for struct enums with underscores
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/structs-enums/struct-enum-ignoring-field-with-underscore.rs | 12 | ||||
| -rw-r--r-- | src/test/ui/structs-enums/struct-enum-ignoring-field-with-underscore.stderr | 24 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/test/ui/structs-enums/struct-enum-ignoring-field-with-underscore.rs b/src/test/ui/structs-enums/struct-enum-ignoring-field-with-underscore.rs new file mode 100644 index 00000000000..c30b8a1e1f1 --- /dev/null +++ b/src/test/ui/structs-enums/struct-enum-ignoring-field-with-underscore.rs @@ -0,0 +1,12 @@ +enum Foo { + Bar { bar: bool }, + Other, +} + +fn main() { + let foo = Some(Foo::Other); + + if let Some(Foo::Bar {_}) = foo {} + //~^ ERROR expected identifier, found reserved identifier `_` + //~| ERROR pattern does not mention field `bar` [E0027] +} diff --git a/src/test/ui/structs-enums/struct-enum-ignoring-field-with-underscore.stderr b/src/test/ui/structs-enums/struct-enum-ignoring-field-with-underscore.stderr new file mode 100644 index 00000000000..16f751444a5 --- /dev/null +++ b/src/test/ui/structs-enums/struct-enum-ignoring-field-with-underscore.stderr @@ -0,0 +1,24 @@ +error: expected identifier, found reserved identifier `_` + --> $DIR/struct-enum-ignoring-field-with-underscore.rs:9:27 + | +LL | if let Some(Foo::Bar {_}) = foo {} + | ^ expected identifier, found reserved identifier + +error[E0027]: pattern does not mention field `bar` + --> $DIR/struct-enum-ignoring-field-with-underscore.rs:9:17 + | +LL | if let Some(Foo::Bar {_}) = foo {} + | ^^^^^^^^^^^^ missing field `bar` + | +help: include the missing field in the pattern + | +LL | if let Some(Foo::Bar {_, bar }) = foo {} + | ~~~~~~~ +help: if you don't care about this missing field, you can explicitly ignore it + | +LL | if let Some(Foo::Bar {_, .. }) = foo {} + | ~~~~~~ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0027`. |
