-
Notifications
You must be signed in to change notification settings - Fork 145
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
Fix up incorrect sub assign behavior and other cleanups #366
Conversation
cc @sunfishcode This cleans up the issue around I haven't changed the behavior of |
In the interests of getting a fix out for the current regression around |
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 | C
won't be printed in formatting output ifA
,B
, andC
have 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 & !b
when there are set bits that don't correspond to known flags.a.difference
will 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_truncate
would remove0b0000_0001
if 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
.