-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Delete EnumSet and remove its final use in rustc #26705
Conversation
To be clear: EnumSet is already deprecated from libstd, and isn't re-exported there. As such you can just delete it. It's an internal implementation detail that was kept in exclusively for rustc's consumption. |
} | ||
|
||
pub fn insert(&mut self, bound: BuiltinBound) { | ||
self.bits = match bound { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.bits |= match ...
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also just cast the BuiltinBound to an integer. So
pub fn insert(&mut self, bound) {
self.bits |= (1 << (bound as u8));
}
pub fn contains(& self, bound) {
((self.bits >> (bound as u8)) & 1) == 1
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good point some of these are probably just my functional programmer side coming through ;)
The collection logic seems legit. |
@jroesch What's the status on this; do you need any more review? r=me if this is good to go. |
@gankro I didn't receive any negative feedback the second time so I assume that we are good to go. |
@bors r+ |
📌 Commit 2c8ab28 has been approved by |
⌛ Testing commit 2c8ab28 with merge 057a1d7... |
💔 Test failed - auto-mac-64-nopt-t |
I didn't run the full test suite since this wasn't a huge change, but one test was still mentioning CLike 😢 |
⌛ Testing commit f4ff8ef with merge ef9570c... |
💔 Test failed - auto-mac-64-nopt-t |
use std::cmp::PartialEq; | ||
|
||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] | ||
pub struct BitSet<N> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this almost exactly the same as bitflags
?
@jroesch seems like a straightforward failure here |
metaquestion: what is the difference between |
One is a macro which declares a statically-sized set, the other is a dynamically-resizing set. |
@arielb1 EnumSet also has a statically known size (number of variants). |
Seems like we can avoid introducing |
This sound plausible, yes. @jroesch what's the status? |
@gankro I had forgot this PR was still hanging around. I fixed the test failure, but we could just use |
☔ The latest upstream changes (presumably #26870) made this pull request unmergeable. Please resolve the merge conflicts. |
I've decided I'm just going to remove BuiltinBounds as per @eddyb 's suggestion will follow up on this PR. |
I'm just going to close this PR, since it sounds like the new one will just be fresh work. Good luck! |
This commit adds an implementation of
BuiltinBounds
that does not depend on external data structures and removesEnumSet
in the standard collections library. We should probably have both a person from the compiler team and libs team look this one over.r? @gankro