Skip to content

Conversation

@moulins
Copy link
Contributor

@moulins moulins commented Jan 13, 2026

Enum variant layouts don't need to store a full LayoutShape; just storing the fields offsets is enough and all other information can be inferred from the parent layout:

  • size, align and ABI don't make much sense for individual variants and should generally be taken from the parent layout instead;
  • variants always have fields: FieldsShape::Arbitrary { .. } and variant: VariantShape::Single { .. }.

In principle, the same refactor could be done on rustc_abi::Layout (see this comment) but I prefer starting with this smaller change first.

Enum variant layouts don't need to store a full `LayoutShape`; just storing
the fields offsets is enough and all other information can be inferred from
the parent layout:
- size, align and ABI don't make much sense for individual variants and
  should generally be taken from the parent layout instead;
- variants always have `fields: FieldsShape::Arbitrary { .. }` and
  `variant: VariantShape::Single { .. }`.
@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 2026

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a, @makai410

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 13, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 2026

r? @celinval

rustbot has assigned @celinval.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants