@@ -23,8 +23,8 @@ passed through the FFI boundary.
23
23
C, and is explicitly contrary to the behavior of an empty type in C++, which
24
24
still consumes a byte of space.
25
25
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.
28
28
29
29
* As an exception to the rule on enum with data, ` Option<&T> ` is
30
30
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
42
42
defined, so this is really a "best guess". In particular, this may be incorrect
43
43
when the C code of interest is compiled with certain flags.
44
44
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
46
46
integer value without a corresponding variant, even though this is
47
47
permitted behavior in C or C++. It is undefined behavior to (unsafely)
48
48
construct an instance of an enum that does not match one of its
@@ -53,19 +53,19 @@ compiled as normal.)
53
53
54
54
# repr(u* ), repr(i* )
55
55
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.
61
61
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
64
64
still a Rust native type, and does not have a stable ABI representation.
65
65
Adding a ` repr ` causes it to be treated exactly like the specified
66
66
integer size for ABI purposes.
67
67
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
69
69
only data is ` PhantomData ` or something else with zero size).
70
70
71
71
Adding an explicit ` repr ` to an enum suppresses the null-pointer
0 commit comments