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

Improve zero discriminant detection for enums #1527

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

djkoloski
Copy link
Member

Enums with negative explicit discriminants can allow variants which are not first but have an implicit discriminant to be assigned a discriminant of zero.

@djkoloski djkoloski requested a review from joshlf July 16, 2024 19:57
@codecov-commenter
Copy link

codecov-commenter commented Jul 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.70%. Comparing base (1336f4b) to head (4d4956e).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1527   +/-   ##
=======================================
  Coverage   87.70%   87.70%           
=======================================
  Files          15       15           
  Lines        5563     5563           
=======================================
  Hits         4879     4879           
  Misses        684      684           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

zerocopy-derive/src/lib.rs Outdated Show resolved Hide resolved
zerocopy-derive/src/lib.rs Outdated Show resolved Hide resolved
zerocopy-derive/src/lib.rs Outdated Show resolved Hide resolved
zerocopy-derive/src/lib.rs Outdated Show resolved Hide resolved
zerocopy-derive/src/lib.rs Outdated Show resolved Hide resolved
@djkoloski djkoloski force-pushed the better_zero_variant_detection branch 2 times, most recently from 91db103 to 8a2b68b Compare July 17, 2024 16:55
@djkoloski djkoloski requested a review from joshlf July 17, 2024 17:08
zerocopy-derive/src/lib.rs Outdated Show resolved Hide resolved
zerocopy-derive/src/lib.rs Outdated Show resolved Hide resolved
zerocopy-derive/src/lib.rs Outdated Show resolved Hide resolved
zerocopy-derive/src/lib.rs Outdated Show resolved Hide resolved
zerocopy-derive/src/lib.rs Show resolved Hide resolved
@djkoloski djkoloski force-pushed the better_zero_variant_detection branch from 8a2b68b to e6e79f7 Compare July 17, 2024 19:57
@djkoloski djkoloski requested a review from joshlf July 17, 2024 21:19
Enums with negative explicit discriminants can allow variants which are
not first but have an implicit discriminant to be assigned a
discriminant of zero. This also adds a help message explaining that the
derive macro ignores discriminants set to const expressions.
@djkoloski djkoloski force-pushed the better_zero_variant_detection branch from e6e79f7 to 4d4956e Compare July 17, 2024 21:50
@djkoloski djkoloski added this pull request to the merge queue Jul 17, 2024
Merged via the queue into google:main with commit 8a0096b Jul 17, 2024
77 checks passed
@djkoloski djkoloski deleted the better_zero_variant_detection branch July 17, 2024 22:15
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.

3 participants