-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an allow-by-default lint that triggers on reachable catch-all / rest patterns #84332
Comments
Unresolved questions:
I would be happy to work on this if somebody can give me some pointers. ¹ allowing one crate to closely replicate a non-exhaustive struct from another crate, with some specific adjustments |
Is this covered by the discussion on issue #69930 or is it distinct? |
No, I don't think so. That issue (and the surrounding discussion) is only about matches on non-exhaustive types in the crate in which they are defined, while this one is about matching external non-exhaustive types, where a catch-all branch can't be avoided but where it's still sometimes useful to know when it becomes reachable with a depedency upgrade. |
@rustbot claim |
There's a subtlety I wanted to point out if someone finds this issue: #[non_exhaustive]
enum Foo {
A(bool),
B
}
match foo {
Foo::A(true) => {}
Foo::B => {}
_ => {}
} |
syn currently allows users to opt into having their tests fail if a match of one of the enums it defines is non-exhaustive:
In the tracking issue for the
#[non_exhaustive]
attribute, it was discussed to allow this in a less hacky way, for truly non-exhaustive enums, with dtolnay suggesting a lint (#44109 (comment)) like this:Later, a clippy issue was opened about the same thing and a PR opened to address it. However, that PR was closed because
The text was updated successfully, but these errors were encountered: