Skip to content

Update comments for -Zrandomize-layout for some guaranteed ZSTs#157905

Draft
zachs18 wants to merge 2 commits into
rust-lang:mainfrom
zachs18:randomize-layout-zst-note
Draft

Update comments for -Zrandomize-layout for some guaranteed ZSTs#157905
zachs18 wants to merge 2 commits into
rust-lang:mainfrom
zachs18:randomize-layout-zst-note

Conversation

@zachs18

@zachs18 zachs18 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

See rust-lang/reference#2262 . T-lang wants to make some additional guarantees about zero-sized repr(Rust) structs and enums, that changes to -Zrandomize-layout could theoretically break in the future. This PR adds comments to -Zrandomize-layout's implementation to prevent breaking those guarantees.

First commit is the guarantees that T-lang is currently FCP'ing in rust-lang/reference#2262 .
Second commit is an additional guarantee that I asked about (that zero-variant repr(Rust) enums are ZSTs) (Marking as draft until T-lang weighs in on this)

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 15, 2026
@zachs18 zachs18 changed the title Randomize layout zst note Update comments for -Zrandomize-layout for some guaranteed ZSTs Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

2 participants