-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Rename C-like enum to Field-less enum #46187
Conversation
There is no need to reference the C programming language to explain this concept.
(rust_highfive has picked a reviewer for you, use r? to override) |
Context: https://internals.rust-lang.org/t/proposal-bikeshed-rename-c-like-enumeration/6209 Randomly reassigning to someone in the docs team… r? @frewsxcv |
Until the decisions is made, we can't accept this PR. |
Pending discussion on #46348 from lang team, i'm reopening this PR. |
Randomly reassigning to member on the lang team… GitHub doesn't accept it, reassigning… r? @nikomatsakis |
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.
The lang team (via @withoutboats) has given a quiet assent for this change, so i'll take it over from a docs perspective.
src/librustc/diagnostics.rs
Outdated
@@ -1641,13 +1641,13 @@ impl Foo { | |||
These attributes do not work on typedefs, since typedefs are just aliases. | |||
|
|||
Representations like `#[repr(u8)]`, `#[repr(i64)]` are for selecting the | |||
discriminant size for C-like enums (when there is no associated data, e.g. | |||
discriminant size for enums with no data fields on any of the variants, e.g. | |||
`enum Color {Red, Blue, Green}`), effectively setting the size of the enum to |
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 took out the opening parenthesis, but left the closing one here (after "enum Color
").
src/librustc/diagnostics.rs
Outdated
`enum Color {Red, Blue, Green}`), effectively setting the size of the enum to | ||
the size of the provided type. Such an enum can be cast to a value of the same | ||
type as well. In short, `#[repr(u8)]` makes the enum behave like an integer | ||
with a constrained set of allowed values. | ||
|
||
Only C-like enums can be cast to numerical primitives, so this attribute will | ||
Only field-less enums can be cast to numerical primitives, so this attribute will |
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.
This line is longer than 80 characters, which caused the build to fail on travis.
Fixed both. |
Excellent! Thanks so much! @bors r+ rollup |
📌 Commit a126a73 has been approved by |
Rename C-like enum to Field-less enum There is no need to reference the C programming language to explain this concept.
☀️ Test successful - status-appveyor, status-travis |
There is no need to reference the C programming language to explain this concept.