Skip to content

Commit 7b637b7

Browse files
committed
Auto merge of rust-lang#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.
2 parents bd7021f + a126a73 commit 7b637b7

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/librustc/diagnostics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,14 +1641,14 @@ impl Foo {
16411641
These attributes do not work on typedefs, since typedefs are just aliases.
16421642
16431643
Representations like `#[repr(u8)]`, `#[repr(i64)]` are for selecting the
1644-
discriminant size for C-like enums (when there is no associated data, e.g.
1645-
`enum Color {Red, Blue, Green}`), effectively setting the size of the enum to
1644+
discriminant size for enums with no data fields on any of the variants, e.g.
1645+
`enum Color {Red, Blue, Green}`, effectively setting the size of the enum to
16461646
the size of the provided type. Such an enum can be cast to a value of the same
16471647
type as well. In short, `#[repr(u8)]` makes the enum behave like an integer
16481648
with a constrained set of allowed values.
16491649
1650-
Only C-like enums can be cast to numerical primitives, so this attribute will
1651-
not apply to structs.
1650+
Only field-less enums can be cast to numerical primitives, so this attribute
1651+
will not apply to structs.
16521652
16531653
`#[repr(packed)]` reduces padding to make the struct size smaller. The
16541654
representation of enums isn't strictly defined in Rust, and this attribute

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5995,7 +5995,7 @@ impl<'a> Parser<'a> {
59955995
match any_disr {
59965996
Some(disr_span) if !all_nullary =>
59975997
self.span_err(disr_span,
5998-
"discriminator values can only be used with a c-like enum"),
5998+
"discriminator values can only be used with a field-less enum"),
59995999
_ => ()
60006000
}
60016001

src/test/parse-fail/issue-17383.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
enum X {
1414
A =
15-
b'a' //~ ERROR discriminator values can only be used with a c-like enum
15+
b'a' //~ ERROR discriminator values can only be used with a field-less enum
1616
,
1717
B(isize)
1818
}

src/test/parse-fail/tag-variant-disr-non-nullary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// compile-flags: -Z parse-only
1212

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

1515
enum color {
1616
red = 0xff0000,

0 commit comments

Comments
 (0)