diff options
| author | bors <bors@rust-lang.org> | 2024-08-08 19:24:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-08-08 19:24:26 +0000 |
| commit | 3e9bd8b566a47c5d1c1dbc7e043b4b7fa5330eca (patch) | |
| tree | 78513342a5cd773102a1d8c16ae826f86efeff74 /compiler/rustc_error_codes/src | |
| parent | 2048386fe2898febe7315c0feb915458e41c7aa5 (diff) | |
| parent | 70dccc2e9b27927bd5e9235f6810686116ee5842 (diff) | |
| download | rust-3e9bd8b566a47c5d1c1dbc7e043b4b7fa5330eca.tar.gz rust-3e9bd8b566a47c5d1c1dbc7e043b4b7fa5330eca.zip | |
Auto merge of #128835 - matthiaskrgr:rollup-apzlbxy, r=matthiaskrgr
Rollup of 7 pull requests
Successful merges:
- #128306 (Update NonNull::align_offset quarantees)
- #128612 (Make `validate_mir` ensure the final MIR for all bodies)
- #128648 (Add regression test)
- #128749 (Mark `{f32,f64}::{next_up,next_down,midpoint}` inline)
- #128795 (Update E0517 message to reflect RFC 2195.)
- #128825 (rm `declared_features` field in resolver)
- #128826 (Only suggest `#[allow]` for `--warn` and `--deny` lint level flags)
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_error_codes/src')
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0517.md | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0517.md b/compiler/rustc_error_codes/src/error_codes/E0517.md index ae802245bd1..5354a08bf31 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0517.md +++ b/compiler/rustc_error_codes/src/error_codes/E0517.md @@ -25,14 +25,17 @@ impl Foo { These attributes do not work on typedefs, since typedefs are just aliases. Representations like `#[repr(u8)]`, `#[repr(i64)]` are for selecting the -discriminant size for enums with no data fields on any of the variants, e.g. -`enum Color {Red, Blue, Green}`, effectively setting the size of the enum to -the size of the provided type. Such an enum can be cast to a value of the same -type as well. In short, `#[repr(u8)]` makes the enum behave like an integer -with a constrained set of allowed values. +discriminant size for enums. For enums with no data fields on any of the +variants, e.g. `enum Color {Red, Blue, Green}`, this effectively sets the size +of the enum to the size of the provided type. Such an enum can be cast to a +value of the same type as well. In short, `#[repr(u8)]` makes a field-less enum +behave like an integer with a constrained set of allowed values. -Only field-less enums can be cast to numerical primitives, so this attribute -will not apply to structs. +For a description of how `#[repr(C)]` and representations like `#[repr(u8)]` +affect the layout of enums with data fields, see [RFC 2195][rfc2195]. + +Only field-less enums can be cast to numerical primitives. Representations like +`#[repr(u8)]` will not apply to structs. `#[repr(packed)]` reduces padding to make the struct size smaller. The representation of enums isn't strictly defined in Rust, and this attribute @@ -42,3 +45,5 @@ won't work on enums. types (i.e., `u8`, `i32`, etc) a representation that permits vectorization via SIMD. This doesn't make much sense for enums since they don't consist of a single list of data. + +[rfc2195]: https://github.com/rust-lang/rfcs/blob/master/text/2195-really-tagged-unions.md |
