Auto merge of #46187 - notriddle:patch-1, r=QuietMisdreavus

Rename C-like enum to Field-less enum

There is no need to reference the C programming language to explain this concept.
This commit is contained in:
bors 2017-12-07 07:16:44 +00:00
commit 7b637b778d
4 changed files with 7 additions and 7 deletions

View file

@ -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

View file

@ -5995,7 +5995,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"),
_ => ()
}

View file

@ -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)
}

View file

@ -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,