Uh oh!
There was an error while loading. Please reload this page.
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.
Gankra
commented
Dec 10, 2014
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. |
tbu-
commented
Dec 10, 2014
The only current use is in the compiler, at the position that is changed by this commit as well. |
Gankra
commented
Dec 10, 2014
I believe Servo and others use it. |
tbu-
commented
Dec 10, 2014
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 (?)). |
SimonSapin
commented
Dec 10, 2014
I don’t really like |
Gankra
commented
Dec 10, 2014
Ah, I see. Okay. I summon @aturon, lord-master of APIs. |
aturon
commented
Dec 11, 2014
Thanks for the PR, @tbu-! I increasingly agree with @SimonSapin here: I don't think |
Gankra
commented
Dec 11, 2014
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. |
SimonSapin
commented
Dec 11, 2014
I’ve exported the git history of the Is that what you meant by handling migrations? |
Gankra
commented
Dec 11, 2014
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. |
SimonSapin
commented
Dec 11, 2014
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. |
aturon
commented
Dec 11, 2014
@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. |
aturon
commented
Dec 18, 2014
I'm going to close this PR now that |
Make
EnumSetportable by using a fixed-size unsigned integer, namelyu32.The previous choice of
uintcreates portability hazards as too high enumvariants are only detected at runtime.
Mark the
from_u32method of the traitCLikeas unsafe, as it is supposed tobe implemented without checking, thus being unsafe.
Remove the memory-unsafe
Decodeimplementation forEnumSet.This is a [breaking-change]. Code using
EnumSetneeds to be updated to useu32s.