Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spec: Improve Definition of Type Layout #1654

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

chorman0773
Copy link
Contributor

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 Finish stabilization of result_ffi_guarantees rust#130628) is documented.
  • The repr(C) layouts are consolidated, though the section on structs 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 of repr(C) as applied to structs 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.

@chorman0773 chorman0773 added A-type-layout Area: type layout T-spec Team: spec labels Oct 17, 2024
@chorman0773
Copy link
Contributor Author

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.

@chorman0773 chorman0773 mentioned this pull request Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-layout Area: type layout T-spec Team: spec
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant