Pattern-matching on #[non_exhaustive]
unit/tuple structs and variants causes confusing diagnostic
#107165
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-patterns
Relating to patterns and pattern matching
D-papercut
Diagnostics: An error or lint that needs small tweaks.
E-help-wanted
Call for participation: Help is requested to fix this issue.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
In crate A:
In crate B:
Current output
Desired output
The error message should reference
#[non_exhaustive]
rather than being implementation-centric. The "variant is private" message is unexpected, confusing the average user since variants don't takepub
or other visibility specifiers.The output should also suggest the fix: use a struct pattern instead, like
Foo::Unit { .. }
andFoo::Tuple{ 0: val, .. }
.Rationale and extra context
Originally a conversation on Mastodon, @estebank suggested I file an issue:
https://hachyderm.io/@predrag/109723971447778736
Other cases
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: