Skip to content

transpile: Do not emit block and init variable for non-bitfield structs#1508

Merged
kkysen merged 1 commit intoimmunant:masterfrom
Rua:skip-struct-init
Dec 11, 2025
Merged

transpile: Do not emit block and init variable for non-bitfield structs#1508
kkysen merged 1 commit intoimmunant:masterfrom
Rua:skip-struct-init

Conversation

@Rua
Copy link
Contributor

@Rua Rua commented Dec 11, 2025

For struct inits, the current generated code looks like

{
    let mut init = Foo { field1: 0 };
    init
}

This syntax is intended to accommodate bitfields, which need their own initialisation statements after the main one. But for normal structs, that isn't necessary. This PR makes it use the struct expression directly in such cases.

Copy link
Contributor

@kkysen kkysen left a comment

Choose a reason for hiding this comment

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

Ooh very nice!

@kkysen kkysen merged commit eaa6c3c into immunant:master Dec 11, 2025
5 checks passed
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