Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up#[derive]'d PartialOrd and Ord use variant declaration order, not explicit discriminant values, for (partially) C-like enums #15523
Comments
huonw
added
the
A-syntaxext
label
Jul 8, 2014
This comment has been minimized.
This comment has been minimized.
|
nominating (for BC-libs, although |
huonw
added
the
A-libs
label
Jul 8, 2014
This was referenced Jul 8, 2014
huonw
added
the
I-nominated
label
Jul 10, 2014
This comment has been minimized.
This comment has been minimized.
|
Assigning 1.0, P-backcompat-libs. (I want to write down what the actual ordering that we want for "partial c-like enums" somewhere, as part of solving this.) |
pnkfelix
added
the
P-backcompat-libs
label
Jul 10, 2014
pnkfelix
added this to the 1.0 milestone
Jul 10, 2014
pnkfelix
removed
the
I-nominated
label
Jul 10, 2014
This comment has been minimized.
This comment has been minimized.
|
spawned off of PR #15503 |
pnkfelix
referenced this issue
Jul 14, 2014
Closed
deriving codegen: add intrinsic to map enum instance to its variant index #15620
This comment has been minimized.
This comment has been minimized.
|
Re-nominating. Is this still an issue we want to tackle? If so, it probably belongs on beta. |
aturon
added
the
I-nominated
label
Jan 8, 2015
nrc
changed the title
#[deriving]'d PartialOrd and Ord use variant declaration order, not explicit discriminant values, for (partially) C-like enums
#[derive]'d PartialOrd and Ord use variant declaration order, not explicit discriminant values, for (partially) C-like enums
Jan 8, 2015
This comment has been minimized.
This comment has been minimized.
|
leaving on the 1.0 milestone, mostly because if we don't actually get around to doing this, it won't be the end of the world (at least, that's IMO) |
brson
added
E-easy
E-mentor
labels
Jan 8, 2015
pnkfelix
removed
the
I-nominated
label
Jan 8, 2015
This comment has been minimized.
This comment has been minimized.
|
@huonw will mentor |
pnkfelix
referenced this issue
Jan 10, 2015
Closed
#[deriving(PartialEq, Show)] generates poor implementations for large enums #20856
This comment has been minimized.
This comment has been minimized.
|
see also #15620 (which strikes me as a logical subtask of this) |
This comment has been minimized.
This comment has been minimized.
|
If we're going to fix this, it needs to be for 1.0. It seems ilke it would be better to just use the discriminant value. |
huonw commentedJul 8, 2014
That is,
derivingconsidersAthe smallest, but it has the largest discriminant.I would think that
#[deriving]should be changed to use the explicit discriminants (if they are available), but there is some possibility that declaration order may be the correct thing (you can always reorder the variants to match their discriminants).There's also an edge case due to the (apparent?) untypedness of enum variant discriminants: when ordering
enum Foo { A = 1, B = -1 }, is the discriminant ofBconsidered negative, or is it positive and huge?