-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Clean up collections::EnumSet
#19679
Conversation
Make `EnumSet` portable by using a fixed-size unsigned integer, namely `u32`. The previous choice of `uint` creates portability hazards as too high enum variants are only detected at runtime. Mark the `from_u32` method of the trait `CLike` as unsafe, as it is supposed to be implemented without checking, thus being unsafe. Remove the memory-unsafe `Decode` implementation for `EnumSet`. This is a [breaking-change]. Code using `EnumSet` needs to be updated to use `u32`s.
I wonder if EnumSet should be generic over an arbitrary UnsignedInt implementor. That way you can have a u8, u32, u64, whatever. CC @SimonSapin or @sfackler I have no idea what EnumSet is really "for" anymore. |
The only current use is in the compiler, at the position that is changed by this commit as well. |
I believe Servo and others use it. |
This doesn't remove functionality for software that is supposed to run on both 32/64 bit systems. So this change should only affect 64-bit only software (but there's not a lot of that (?)). |
I don’t really like |
Ah, I see. Okay. I summon @aturon, lord-master of APIs. |
Thanks for the PR, @tbu-! I increasingly agree with @SimonSapin here: I don't think |
Yes I'm happy to adopt this and any other "imperfect" collections in collect-rs. I'm not sure how we want to handle such migrations. |
I’ve exported the git history of the Is that what you meant by handling migrations? |
I was more thinking about the actual political process. e.g. an RFC or a core-team meeting or what. But yeah having a nod to actual commit history would be nice. |
Since removing things is a breaking change, probably an RFC. (And whatever the RFC approval process is these days − it’s changing but I haven’t read up on that yet.) But you can have a couple of related things in the same RFC. |
@gankro Maybe your collections reform part 2 RFC should also include this migration. If you want to do that, we should talk about the other collections that we don't plan to stabilize in the near future and probably move them as well. |
I'm going to close this PR now that |
Make
EnumSet
portable by using a fixed-size unsigned integer, namelyu32
.The previous choice of
uint
creates portability hazards as too high enumvariants are only detected at runtime.
Mark the
from_u32
method of the traitCLike
as unsafe, as it is supposed tobe implemented without checking, thus being unsafe.
Remove the memory-unsafe
Decode
implementation forEnumSet
.This is a [breaking-change]. Code using
EnumSet
needs to be updated to useu32
s.