File tree 1 file changed +7
-2
lines changed
compiler/rustc_error_codes/src/error_codes
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,11 @@ of the enum to the size of the provided type. Such an enum can be cast to a
31
31
value of the same type as well. In short, ` #[repr(u8)] ` makes a field-less enum
32
32
behave like an integer with a constrained set of allowed values.
33
33
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.
36
39
37
40
` #[repr(packed)] ` reduces padding to make the struct size smaller. The
38
41
representation of enums isn't strictly defined in Rust, and this attribute
@@ -42,3 +45,5 @@ won't work on enums.
42
45
types (i.e., ` u8 ` , ` i32 ` , etc) a representation that permits vectorization via
43
46
SIMD. This doesn't make much sense for enums since they don't consist of a
44
47
single list of data.
48
+
49
+ [ rfc2915 ] : https://github.com/rust-lang/rfcs/blob/master/text/2195-really-tagged-unions.md
You can’t perform that action at this time.
0 commit comments