Skip to content
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

Merged
merged 4 commits into from Apr 6, 2021
Merged

add non_exhaustive to public enums #1426

merged 4 commits into from Apr 6, 2021

Conversation

bluejekyll
Copy link
Member

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

@codecov
Copy link

codecov bot commented Mar 30, 2021

Codecov Report

Merging #1426 (2642183) into main (f483926) will decrease coverage by 0.02%.
The diff coverage is 0.00%.

@@            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     

@djc
Copy link
Collaborator

djc commented Mar 30, 2021

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.

@bluejekyll
Copy link
Member Author

ok, let me clean this up and get it ready.

@bluejekyll bluejekyll marked this pull request as ready for review April 1, 2021 20:41
@bluejekyll bluejekyll force-pushed the non_exhaustive_patterns branch 2 times, most recently from 44b8833 to d2fc75b Compare April 3, 2021 17:33
@bluejekyll
Copy link
Member Author

Ok @djc I think this is ready, unless you see something missing.

@bluejekyll
Copy link
Member Author

@djc any concerns with me merging this?

@djc
Copy link
Collaborator

djc commented Apr 5, 2021

I can review it tomorrow.

@djc djc merged commit 0c07d00 into main Apr 6, 2021
@djc djc deleted the non_exhaustive_patterns branch April 6, 2021 08:29
@djc
Copy link
Collaborator

djc commented Apr 6, 2021

Nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

trust-dns-proto 0.20.1 contains BC breakage
2 participants