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

Copy link
Member

@makai410 makai410 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good to me. Per past rustc_public development experience, we usually just chase the unstable rustc, whereas I think it's the first time we're changing rustc_public first :) But anyway it's a good cleanup, so

View changes since this review

@makai410
Copy link
Member

r? @makai410
@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 26, 2026

📌 Commit 3777ebc has been approved by makai410

It is now in the queue for this repository.

@rust-bors rust-bors bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jan 26, 2026
@rust-bors rust-bors bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 26, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 26, 2026

rust-bors bot pushed a commit that referenced this pull request Jan 26, 2026
Don't expose redundant information in `rustc_public`'s `LayoutShape`

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](#113988 (comment))) but I prefer starting with this smaller change first.
@JonathanBrouwer
Copy link
Contributor

@bors yield
Closing tree, see #151701

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 26, 2026

Auto build cancelled. Cancelled workflows:

The next pull request likely to be tested is #151040.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jan 26, 2026
…akai410

Don't expose redundant information in `rustc_public`'s `LayoutShape`

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](rust-lang#113988 (comment))) but I prefer starting with this smaller change first.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 26, 2026
…akai410

Don't expose redundant information in `rustc_public`'s `LayoutShape`

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](rust-lang#113988 (comment))) but I prefer starting with this smaller change first.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 26, 2026
…akai410

Don't expose redundant information in `rustc_public`'s `LayoutShape`

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](rust-lang#113988 (comment))) but I prefer starting with this smaller change first.
rust-bors bot pushed a commit that referenced this pull request Jan 27, 2026
Rollup of 6 pull requests

Successful merges:

 - #148718 (Do not mention `-Zmacro-backtrace` for std macros that are a wrapper around a compiler intrinsic)
 - #151137 (checksum-freshness: Fix invalid checksum calculation for binary files)
 - #150863 (Adds two new Tier 3 targets - `aarch64v8r-unknown-none{,-softfloat}`)
 - #151040 (Don't expose redundant information in `rustc_public`'s `LayoutShape`)
 - #151699 (Update books)
 - #151700 (os allow missing_docs)
rust-bors bot pushed a commit that referenced this pull request Jan 27, 2026
Rollup of 12 pull requests

Successful merges:

 - #147996 (Stabilize ppc inline assembly)
 - #148718 (Do not mention `-Zmacro-backtrace` for std macros that are a wrapper around a compiler intrinsic)
 - #151137 (checksum-freshness: Fix invalid checksum calculation for binary files)
 - #151680 (Update backtrace and windows-bindgen)
 - #150863 (Adds two new Tier 3 targets - `aarch64v8r-unknown-none{,-softfloat}`)
 - #151040 (Don't expose redundant information in `rustc_public`'s `LayoutShape`)
 - #151383 (remove `#[deprecated]` from unstable & internal `SipHasher13` and `24` types)
 - #151529 (lint: Use rustc_apfloat for `overflowing_literals`, add f16 and f128)
 - #151669 (rename uN::{gather,scatter}_bits to uN::{extract,deposit}_bits)
 - #151689 (Fix broken Xtensa installation link)
 - #151699 (Update books)
 - #151700 (os allow missing_docs)
@rust-bors rust-bors bot merged commit 957801b into rust-lang:main Jan 27, 2026
11 of 12 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Jan 27, 2026
rust-timer added a commit that referenced this pull request Jan 27, 2026
Rollup merge of #151040 - moulins:public-variant-layout, r=makai410

Don't expose redundant information in `rustc_public`'s `LayoutShape`

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](#113988 (comment))) but I prefer starting with this smaller change first.
@moulins moulins deleted the public-variant-layout branch January 27, 2026 12:40
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jan 28, 2026
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#147996 (Stabilize ppc inline assembly)
 - rust-lang/rust#148718 (Do not mention `-Zmacro-backtrace` for std macros that are a wrapper around a compiler intrinsic)
 - rust-lang/rust#151137 (checksum-freshness: Fix invalid checksum calculation for binary files)
 - rust-lang/rust#151680 (Update backtrace and windows-bindgen)
 - rust-lang/rust#150863 (Adds two new Tier 3 targets - `aarch64v8r-unknown-none{,-softfloat}`)
 - rust-lang/rust#151040 (Don't expose redundant information in `rustc_public`'s `LayoutShape`)
 - rust-lang/rust#151383 (remove `#[deprecated]` from unstable & internal `SipHasher13` and `24` types)
 - rust-lang/rust#151529 (lint: Use rustc_apfloat for `overflowing_literals`, add f16 and f128)
 - rust-lang/rust#151669 (rename uN::{gather,scatter}_bits to uN::{extract,deposit}_bits)
 - rust-lang/rust#151689 (Fix broken Xtensa installation link)
 - rust-lang/rust#151699 (Update books)
 - rust-lang/rust#151700 (os allow missing_docs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

5 participants