missing fields in a struct pattern for a tuple variant syntax produces a flawed error #108284
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Suppose you have an enum with a tuple variant, and you try to match it with a struct pattern using field indices instead of names, but you forget some of the fields. Besides the missing fields, this is valid, but the error just tells you to switch to tuple variant syntax. (playground)
The error message you would have gotten if you had used tuple variant syntax is nicer (playground):
It might be nice to change the first error to be more like the second. Something like:
On the other hand, we might not want to do this: it risks being confusing to beginners, and unless you're writing a macro, you probably shouldn't use struct variant syntax to match a tuple variant.
We could add yet another note explaining that:
but that might be too much.
Tested in today's playground (1.69.0-nightly 2023-02-17 7aa413d).
Somewhat related to/may interact with #79652.
The text was updated successfully, but these errors were encountered: