-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #95238 - TaKO8Ki:stop-emitting-E0026-for-struct-enum-…
…with-underscore, r=estebank Stop emitting E0026 for struct enums with underscores This patch resolves a part of #83263; r? `@estebank`
- Loading branch information
Showing
3 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/test/ui/structs-enums/struct-enum-ignoring-field-with-underscore.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] | ||
} |
24 changes: 24 additions & 0 deletions
24
src/test/ui/structs-enums/struct-enum-ignoring-field-with-underscore.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |