Skip to content

Commit aed22ff

Browse files
authored
Merge pull request #46 from Havvy/field-less-enums
Rename C-like enums to field-less enums
2 parents 2629717 + 3dc8969 commit aed22ff

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/casts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ primitive:
2828
* `*T as integer`
2929
* `integer as *T`
3030
* `number as number`
31-
* `C-like-enum as integer`
31+
* `field-less enum as integer`
3232
* `bool as integer`
3333
* `char as integer`
3434
* `u8 as char`

src/other-reprs.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ passed through the FFI boundary.
2323
C, and is explicitly contrary to the behavior of an empty type in C++, which
2424
still consumes a byte of space.
2525

26-
* DST pointers (fat pointers), tuples, and enums with data (that is, non-C-like
27-
enums) are not a concept in C, and as such are never FFI-safe.
26+
* DST pointers (fat pointers), tuples, and enums with fields are not a concept
27+
in C, and as such are never FFI-safe.
2828

2929
* As an exception to the rule on enum with data, `Option<&T>` is
3030
FFI-safe if `*const T` is FFI-safe, and they have the same
@@ -42,7 +42,7 @@ binary interface (ABI). Note that enum representation in C is implementation
4242
defined, so this is really a "best guess". In particular, this may be incorrect
4343
when the C code of interest is compiled with certain flags.
4444

45-
* "C-like" enums with `repr(C)` or `repr(u*)` still may not be set to an
45+
* Field-less enums with `repr(C)` or `repr(u*)` still may not be set to an
4646
integer value without a corresponding variant, even though this is
4747
permitted behavior in C or C++. It is undefined behavior to (unsafely)
4848
construct an instance of an enum that does not match one of its
@@ -53,19 +53,19 @@ compiled as normal.)
5353

5454
# repr(u*), repr(i*)
5555

56-
These specify the size to make a C-like enum. If the discriminant overflows the
57-
integer it has to fit in, it will produce a compile-time error. You can manually
58-
ask Rust to allow this by setting the overflowing element to explicitly be 0.
59-
However Rust will not allow you to create an enum where two variants have the
60-
same discriminant.
56+
These specify the size to make a field-less enum. If the discriminant overflows
57+
the integer it has to fit in, it will produce a compile-time error. You can
58+
manually ask Rust to allow this by setting the overflowing element to explicitly
59+
be 0. However Rust will not allow you to create an enum where two variants have
60+
the same discriminant.
6161

62-
The term "C-like enum" only means that the enum doesn't have data in any
63-
of its variants. A C-like enum without a `repr(u*)` or `repr(C)` is
62+
The term "field-less enum" only means that the enum doesn't have data in any
63+
of its variants. A field-less enum without a `repr(u*)` or `repr(C)` is
6464
still a Rust native type, and does not have a stable ABI representation.
6565
Adding a `repr` causes it to be treated exactly like the specified
6666
integer size for ABI purposes.
6767

68-
A non-C-like enum is a Rust type with no guaranteed ABI (even if the
68+
Any enum with fields is a Rust type with no guaranteed ABI (even if the
6969
only data is `PhantomData` or something else with zero size).
7070

7171
Adding an explicit `repr` to an enum suppresses the null-pointer

src/repr-rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Rust gives you the following ways to lay out composite data:
2121
* arrays (homogeneous product types)
2222
* enums (named sum types -- tagged unions)
2323

24-
An enum is said to be *C-like* if none of its variants have associated data.
24+
An enum is said to be *field-less* if none of its variants have associated data.
2525

2626
Composite structures will have an alignment equal to the maximum
2727
of their fields' alignment. Rust will consequently insert padding where

0 commit comments

Comments
 (0)