wasm: fix ABI for enums with integer layout and ZST fields - #162826
Merged
Merged
Conversation
changes in later commits need this case out of the way
Member
|
@bors r+ Thanks for this! Perhaps at some point in the future I'd love to pick your brain on the ABI going-ons here to the extent that I want to define a new ABI for wasm where that'd be a good spot to fix all quirks we know of, but that's a conversation for a later time... |
Contributor
Zalathar
added a commit
to Zalathar/rust
that referenced
this pull request
Sep 16, 2026
…excrichton wasm: fix ABI for enums with integer layout and ZST fields fixes rust-lang#121408 follow-up to rust-lang#162806 Clang is doing something that is rather annoying for us to emulate: like with unions it looks at the structure of the type, not the representation. But in rust an `enum` that is represented as an integer is not considered an `aggregate` at all, yet may still need to be passed as one if it has any (even ZST) fields. r? alexcrichton cc @hanna-kruppe
rust-bors Bot
pushed a commit
that referenced
this pull request
Sep 16, 2026
Rollup of 7 pull requests Successful merges: - #156216 (implement const Iterator for Range) - #162748 (Enable LLVM Thin LTO for LoongArch64) - #162769 (Yeet the `DeepRegionResolver` (earlier called `OpportunisticRegionResolver`)) - #162800 (Cleanups related to RefDecodable) - #162826 (wasm: fix ABI for enums with integer layout and ZST fields) - #159359 ([rustc_public] Enhance PassMode API) - #162818 (Add regression test for malformed RPITIT bound ICE with the new solver)
bjorn3
reviewed
Sep 16, 2026
| { | ||
| // The base case: a single scalar is a singleton scalar. | ||
| if !layout.is_aggregate() { | ||
| if !(layout.is_aggregate() || layout.peel_transparent_wrappers(cx).is_enum()) { |
Member
There was a problem hiding this comment.
I would have expected enums with data to already be considered an aggregate when #[repr] other than #[repr(Rust)] is used, even if the data is a ZST.
rust-bors Bot
pushed a commit
that referenced
this pull request
Sep 16, 2026
Rollup of 10 pull requests Successful merges: - #156216 (implement const Iterator for Range) - #160697 (rustc: Tweak the effect of `--jobs` on frontend parallelism) - #162748 (Enable LLVM Thin LTO for LoongArch64) - #162769 (Yeet the `DeepRegionResolver` (earlier called `OpportunisticRegionResolver`)) - #162794 (Simplify `ast::UseTreeKind`) - #162800 (Cleanups related to RefDecodable) - #162826 (wasm: fix ABI for enums with integer layout and ZST fields) - #159359 ([rustc_public] Enhance PassMode API) - #162196 (Offload cmake cleanups) - #162818 (Add regression test for malformed RPITIT bound ICE with the new solver)
rust-bors Bot
pushed a commit
that referenced
this pull request
Sep 16, 2026
Rollup merge of #162826 - folkertdev:wasm-int-enum-abi, r=alexcrichton wasm: fix ABI for enums with integer layout and ZST fields fixes #121408 follow-up to #162806 Clang is doing something that is rather annoying for us to emulate: like with unions it looks at the structure of the type, not the representation. But in rust an `enum` that is represented as an integer is not considered an `aggregate` at all, yet may still need to be passed as one if it has any (even ZST) fields. r? alexcrichton cc @hanna-kruppe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #121408
follow-up to #162806
Clang is doing something that is rather annoying for us to emulate: like with unions it looks at the structure of the type, not the representation. But in rust an
enumthat is represented as an integer is not considered anaggregateat all, yet may still need to be passed as one if it has any (even ZST) fields.r? alexcrichton
cc @hanna-kruppe