Skip to content

cmse: clear variant-dependent padding#159466

Open
folkertdev wants to merge 5 commits into
rust-lang:mainfrom
folkertdev:clear-variant-dependent-padding
Open

cmse: clear variant-dependent padding#159466
folkertdev wants to merge 5 commits into
rust-lang:mainfrom
folkertdev:clear-variant-dependent-padding

Conversation

@folkertdev

Copy link
Copy Markdown
Contributor

tracking issue: #81391
tracking issue: #75835

Since #157397 we clear variant-independent padding, bytes that are padding for all valid values of the type. This PR extends that idea to also clear variant-dependent padding, where we have to check what variant a (nested) enum has to determine which bytes are padding so we can clear them.

With these changes the lint from #147697 can lint on just unions.

r? @davidtwco
cc @RalfJung @Jules-Bertholet

@folkertdev folkertdev added F-cmse_nonsecure_entry `#![feature(cmse_nonsecure_entry)]` F-abi_cmse_nonsecure_call `#![feature(abi_cmse_nonsecure_call)]` labels Jul 17, 2026
@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 Jul 17, 2026
@programmerjake

Copy link
Copy Markdown
Member

maybe add a check that Option<MaybeUninit<u8>> correctly warns/errors (if there's not already a check)?

@folkertdev

Copy link
Copy Markdown
Contributor Author

The lint is in #147697 (but needs updating now). It triggers when MaybeUninit or any other union is part of a type.

Comment thread compiler/rustc_abi/src/layout/ty.rs Outdated
Comment thread compiler/rustc_codegen_ssa/src/mir/block.rs Outdated
Comment thread compiler/rustc_codegen_ssa/src/mir/block.rs Outdated

@RalfJung RalfJung Jul 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I can't see any test here covering nested enums?

View changes since the review

@folkertdev
folkertdev force-pushed the clear-variant-dependent-padding branch from 6e5759f to 0fe4afc Compare July 18, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-abi_cmse_nonsecure_call `#![feature(abi_cmse_nonsecure_call)]` F-cmse_nonsecure_entry `#![feature(cmse_nonsecure_entry)]` 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.

5 participants