Skip to content

type-layout: rewrite #[repr(C)] struct layout algorithm#2243

Merged
traviscross merged 1 commit into
rust-lang:masterfrom
DanielEScherzer:type-layout-algo
Jun 23, 2026
Merged

type-layout: rewrite #[repr(C)] struct layout algorithm#2243
traviscross merged 1 commit into
rust-lang:masterfrom
DanielEScherzer:type-layout-algo

Conversation

@DanielEScherzer

@DanielEScherzer DanielEScherzer commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Make the code actual compile by defining types, not using a variable named struct, adding mut where needed, etc.

Properly handle the max() alignment call returning Option<usize> rather than usize by using 1 for the alignment if there are no fields.

Add comments with the parts of the algorithm that are represented by the statements.

Also include a runnable example hidden by default.

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Apr 28, 2026
@DanielEScherzer DanielEScherzer force-pushed the type-layout-algo branch 6 times, most recently from d49cb73 to 98e21c5 Compare May 5, 2026 19:32
@DanielEScherzer

This comment was marked as resolved.

@DanielEScherzer DanielEScherzer marked this pull request as draft May 5, 2026 20:24
@rustbot rustbot removed the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label May 5, 2026
@DanielEScherzer DanielEScherzer marked this pull request as ready for review May 26, 2026 18:55
@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label May 26, 2026
@rustbot

rustbot commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@DanielEScherzer DanielEScherzer force-pushed the type-layout-algo branch 2 times, most recently from 63463ca to fcf1220 Compare June 23, 2026 20:07
Make the code actual compile by defining types, not using a variable named
`struct`, adding `mut` where needed, etc.

Properly handle the `max()` alignment call returning `Option<usize>` rather
than `usize` by using 1 for the alignment if there are no fields.

Add comments with the parts of the algorithm that are represented by the
statements.

Also include a runnable example hidden by default.
@traviscross

Copy link
Copy Markdown
Contributor

Thanks @DanielEScherzer.

@traviscross traviscross added this pull request to the merge queue Jun 23, 2026
@traviscross traviscross removed the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Jun 23, 2026
Merged via the queue into rust-lang:master with commit e097e1b Jun 23, 2026
6 checks passed
@DanielEScherzer DanielEScherzer deleted the type-layout-algo branch June 23, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants