Fix up incorrect sub assign behavior and other cleanups#366
Merged
KodrAus merged 15 commits intobitflags:mainfrom Jun 27, 2023
Merged
Fix up incorrect sub assign behavior and other cleanups#366KodrAus merged 15 commits intobitflags:mainfrom
KodrAus merged 15 commits intobitflags:mainfrom
Conversation
KodrAus
commented
Jun 26, 2023
KodrAus
commented
Jun 26, 2023
KodrAus
commented
Jun 26, 2023
Member
Author
|
cc @sunfishcode This cleans up the issue around I haven't changed the behavior of |
This was referenced Jun 26, 2023
Member
Author
|
In the interests of getting a fix out for the current regression around |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #365
Closes #364
This PR reworks our test suite to more rigorously test each method on flags types and fixes up the issue of
-and-=having different results with unknown bits.This PR makes the following behavioral changes and clarifications:
-=now behaves the same as-anddifference: It respects set bits that don't correspond to known flags.const ABC = A | B | Cwon't be printed in formatting output ifA,B, andChave already been printed. Formatting just prints some set of flags that will produce an equal bitpattern when parsed. It doesn't necessarily print every flag that intersects the value.a.difference(b)is not the same asa & !bwhen there are set bits that don't correspond to known flags.a.differencewill respect them, but!will unset them.!will use!self.bits() & Self::all().bits()instead ofSelf::from_bits_truncate(!self.bits()). This is a very subtle distinction.Self::from_bits_truncatewould remove0b0000_0001if the only valid flag was0b1111_1111, but& Self::all().bits()will retain0b0000_0001. It retains more bits when there are bits that don't correspond to a known flag, and there is a multi-bit flag defined that does cover them. This is unlikely to have any practical implication until we recommend the flagconst ALL = !0.