diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 8089a88a9e8d483a3b2ca0a1ca612a6282f45b25..85ae529ae329a62cb152aa068563f1c4a9837d3a 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -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 diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 2461e65585f5a1e1f4dc4cc666030dfc65717089..726db7334824ec033a56ad98d5c38e4818564e35 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5995,7 +5995,7 @@ fn parse_enum_def(&mut self, _generics: &ast::Generics) -> PResult<'a, EnumDef> 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"), _ => () } diff --git a/src/test/parse-fail/issue-17383.rs b/src/test/parse-fail/issue-17383.rs index 1b33cb388575845b54a7b41cbaea88ecbbe6be3c..48f629fd82873d345a3088fa886f73f6514e0d34 100644 --- a/src/test/parse-fail/issue-17383.rs +++ b/src/test/parse-fail/issue-17383.rs @@ -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) } diff --git a/src/test/parse-fail/tag-variant-disr-non-nullary.rs b/src/test/parse-fail/tag-variant-disr-non-nullary.rs index f90b1cc94bb1be04c7745d9aa8b55a4a4c74f65b..2d86589285c1aaad49f995008108430b3bcb1b1a 100644 --- a/src/test/parse-fail/tag-variant-disr-non-nullary.rs +++ b/src/test/parse-fail/tag-variant-disr-non-nullary.rs @@ -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,