Skip to content

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

Draft
DanielEScherzer wants to merge 2 commits intorust-lang:masterfrom
DanielEScherzer:type-layout-algo
Draft

type-layout: rewrite #[repr(C)] struct layout algorithm#2243
DanielEScherzer wants to merge 2 commits intorust-lang:masterfrom
DanielEScherzer:type-layout-algo

Conversation

@DanielEScherzer
Copy link
Copy Markdown
Contributor

@DanielEScherzer DanielEScherzer commented Apr 28, 2026

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.

Add new layout.repr.c.struct.align-empty rule.

@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 5 times, most recently from f12e92e to d49cb73 Compare May 5, 2026 19:31
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.
@DanielEScherzer
Copy link
Copy Markdown
Contributor Author

This should wait until after the new guarantee is added in #2264

@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
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.

2 participants