Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

jroesch
Copy link
Member

@jroesch jroesch commented Jul 1, 2015

This commit adds an implementation of BuiltinBounds that does not depend on external data structures and removes EnumSet 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

@Gankra
Copy link
Contributor

Gankra commented Jul 1, 2015

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.bits |= match ... ?

Copy link
Contributor

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
}

Copy link
Member Author

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 ;)

@Gankra
Copy link
Contributor

Gankra commented Jul 1, 2015

The collection logic seems legit.

@jroesch jroesch changed the title Deprecate EnumSet and remove its final use in rustc Delete EnumSet and remove its final use in rustc Jul 1, 2015
@Gankra
Copy link
Contributor

Gankra commented Jul 5, 2015

@jroesch What's the status on this; do you need any more review? r=me if this is good to go.

@jroesch
Copy link
Member Author

jroesch commented Jul 6, 2015

@gankro I didn't receive any negative feedback the second time so I assume that we are good to go.

@Gankra
Copy link
Contributor

Gankra commented Jul 7, 2015

@bors r+

@bors
Copy link
Contributor

bors commented Jul 7, 2015

📌 Commit 2c8ab28 has been approved by Gankro

@bors
Copy link
Contributor

bors commented Jul 8, 2015

⌛ Testing commit 2c8ab28 with merge 057a1d7...

@bors
Copy link
Contributor

bors commented Jul 8, 2015

💔 Test failed - auto-mac-64-nopt-t

@jroesch
Copy link
Member Author

jroesch commented Jul 8, 2015

I didn't run the full test suite since this wasn't a huge change, but one test was still mentioning CLike 😢

@alexcrichton
Copy link
Member

@bors: r=Gankro f4ff8ef

@bors
Copy link
Contributor

bors commented Jul 8, 2015

⌛ Testing commit f4ff8ef with merge ef9570c...

@bors
Copy link
Contributor

bors commented Jul 8, 2015

💔 Test failed - auto-mac-64-nopt-t

use std::cmp::PartialEq;

#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub struct BitSet<N> {
Copy link
Contributor

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?

@steveklabnik
Copy link
Member

@jroesch seems like a straightforward failure here

@tamird
Copy link
Contributor

tamird commented Jul 19, 2015

metaquestion: what is the difference between EnumSet/BitSet and bitflags?

@arielb1
Copy link
Contributor

arielb1 commented Jul 19, 2015

@tamird

One is a macro which declares a statically-sized set, the other is a dynamically-resizing set.

@Gankra
Copy link
Contributor

Gankra commented Jul 19, 2015

@arielb1 EnumSet also has a statically known size (number of variants).

@tamird
Copy link
Contributor

tamird commented Jul 20, 2015

Seems like we can avoid introducing BitSet and just use bitflags!

@Gankra
Copy link
Contributor

Gankra commented Jul 20, 2015

This sound plausible, yes. @jroesch what's the status?

@jroesch
Copy link
Member Author

jroesch commented Jul 20, 2015

@gankro I had forgot this PR was still hanging around. I fixed the test failure, but we could just use bitflags if you don't foresee any problems.

@bors
Copy link
Contributor

bors commented Jul 26, 2015

☔ The latest upstream changes (presumably #26870) made this pull request unmergeable. Please resolve the merge conflicts.

@jroesch
Copy link
Member Author

jroesch commented Jul 26, 2015

I've decided I'm just going to remove BuiltinBounds as per @eddyb 's suggestion will follow up on this PR.

@Gankra
Copy link
Contributor

Gankra commented Jul 27, 2015

I'm just going to close this PR, since it sounds like the new one will just be fresh work.

Good luck!

@Gankra Gankra closed this Jul 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants