Skip to content

Commit f02ae6f

Browse files
committed
Add link to RFC 2915 for data-ful enums with reprs
and clarify which attribute is being referred to in the next paragraph.
1 parent b509ff2 commit f02ae6f

File tree

1 file changed

+7
-2
lines changed
  • compiler/rustc_error_codes/src/error_codes

1 file changed

+7
-2
lines changed

compiler/rustc_error_codes/src/error_codes/E0517.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ of the enum to the size of the provided type. Such an enum can be cast to a
3131
value of the same type as well. In short, `#[repr(u8)]` makes a field-less enum
3232
behave like an integer with a constrained set of allowed values.
3333

34-
Only field-less enums can be cast to numerical primitives. This attribute
35-
will not apply to structs.
34+
For a description of how `#[repr(C)]` and representations like `#[repr(u8)]`
35+
affect the layout of enums with data fields, see [RFC 2915][rfc2915].
36+
37+
Only field-less enums can be cast to numerical primitives. Representations like
38+
`#[repr(u8)]` will not apply to structs.
3639

3740
`#[repr(packed)]` reduces padding to make the struct size smaller. The
3841
representation of enums isn't strictly defined in Rust, and this attribute
@@ -42,3 +45,5 @@ won't work on enums.
4245
types (i.e., `u8`, `i32`, etc) a representation that permits vectorization via
4346
SIMD. This doesn't make much sense for enums since they don't consist of a
4447
single list of data.
48+
49+
[rfc2915]: https://github.com/rust-lang/rfcs/blob/master/text/2195-really-tagged-unions.md

0 commit comments

Comments
 (0)