reference
reference copied to clipboard
Spec: Improve Definition of Type Layout
This improves the definition of Type Layout to be more formal. The following changes are made:
- The guarantees of repr(Rust) structs and unions are defined in a separate section, as they apply to all structs and unions, even when they have another representation.
- The layout of
repr(Rust)enums is documented, with some permissions granted conservatively to implementations (like not including uninhabited variants in the size/alignment of the enum), pending approval either way.- I'm not too attached to including these, but omitting them could be taken as a prohibition against them in the future.
- Discriminant Elision (now guaranteed by https://github.com/rust-lang/rust/pull/130628) is documented.
- This is intended the supersede https://github.com/rust-lang/unsafe-code-guidelines/pull/538.
- The
repr(C)layouts are consolidated, though the section onstructs is left presently. I'm not sure whether to get rid of it or replace it with a large note admonition, because it isn't needed as normative text, but the definition ofrepr(C)as applied tostructs can be confusing on its own.
I think there's some more work to be done on the chapter, but I think this is a reasonable set of stuff to do in one PR, specifically targetted at the repr attribute.
Link check errors are intentional in bea8b9d - I link to sections from #1618 and omitted the footnot references so it can be reverted when #1618 is merged.
:umbrella: The latest upstream changes (possibly f80986bb34aa67f30bbb6b92f7b69b250e275126) made this pull request unmergeable. Please resolve the merge conflicts.