-
Notifications
You must be signed in to change notification settings - Fork 422
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 non_exhaustive to public enums #1426
Conversation
0033877
to
8da5f8d
Compare
Codecov Report
@@ Coverage Diff @@
## main #1426 +/- ##
==========================================
- Coverage 83.71% 83.69% -0.02%
==========================================
Files 167 167
Lines 15865 15867 +2
==========================================
- Hits 13280 13279 -1
- Misses 2585 2588 +3 |
In my opinion, semver compatibility trumps the ability to exhaustively match enums. The contract that semver-compatible versions should just compile is widely upheld, and we should not mess with it. The clippy lint seems like a fine solution for those who really want to make sure they match every variant. |
ok, let me clean this up and get it ready. |
44b8833
to
d2fc75b
Compare
Ok @djc I think this is ready, unless you see something missing. |
d2fc75b
to
4ff167c
Compare
4ff167c
to
2642183
Compare
@djc any concerns with me merging this? |
I can review it tomorrow. |
Nice work! |
I don't know if we want to make this guarantee. But It's worth putting it up for discussion.
We know that record types will be coming in the future, but adding non_exhaustive to RecordType is also a bit annoying because the RecordTypes are mostly fixed. So The question here is, where do we want to add non_exhaustive such that minor and patch releases are forward compatible. Do we want to make forward compatibility a guarantee on perhaps on patch releases, but not minor releases? See #1425, which happened on a pre 1.0 patch release as an example.
How extreme do we want to be on this at the detriment of losing one of Rusts greatest checks (all enum variants are covered in a match statement).
Fixes: #1425