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

Rename C-like enum to Field-less enum #46187

Merged
merged 6 commits into from
Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1641,14 +1641,14 @@ 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.
`enum Color {Red, Blue, Green}`), effectively setting the size of the enum to
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
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
not apply to structs.
Only field-less enums can be cast to numerical primitives, so this attribute
will not apply to structs.

`#[repr(packed)]` reduces padding to make the struct size smaller. The
representation of enums isn't strictly defined in Rust, and this attribute
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5891,7 +5891,7 @@ impl<'a> Parser<'a> {
match any_disr {
Some(disr_span) if !all_nullary =>
self.span_err(disr_span,
"discriminator values can only be used with a c-like enum"),
"discriminator values can only be used with a field-less enum"),
_ => ()
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/parse-fail/issue-17383.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

enum X {
A =
b'a' //~ ERROR discriminator values can only be used with a c-like enum
b'a' //~ ERROR discriminator values can only be used with a field-less enum
,
B(isize)
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/parse-fail/tag-variant-disr-non-nullary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// compile-flags: -Z parse-only

//error-pattern: discriminator values can only be used with a c-like enum
//error-pattern: discriminator values can only be used with a field-less enum

enum color {
red = 0xff0000,
Expand Down