-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Omit discriminant from nullary univariant enums.
If an enum is isomorphic to unit, there's no need to use any bits to represent it. The only obvious reason this wasn't the case was because the enum could be C-like and have a user-specified discriminant -- but that value is constant, so it doesn't need to be stored. This change means that all newtype-like enums have the same size (and layout) as their underlying type, which might be a useful property to have, at least in terms of making programs' low-level behavior less surprising.
- Loading branch information
Showing
3 changed files
with
29 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3742b62
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.
saw approval from graydon
at jld@3742b62
3742b62
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.
merging jld/rust/enum-unitlike = 3742b62 into auto
3742b62
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.
jld/rust/enum-unitlike = 3742b62 merged ok, testing candidate = 0f04df8
3742b62
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.
all tests pass:
http://buildbot.rust-lang.org/builders/auto-linux/builds/84
http://buildbot.rust-lang.org/builders/auto-win/builds/79
http://buildbot.rust-lang.org/builders/auto-mac/builds/81
3742b62
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.
fast-forwarding incoming to auto = 0f04df8