Skip to content

Fix lifetime issues for native subexpressions in bsn! enum variants#24876

Open
akshitj11 wants to merge 1 commit into
bevyengine:mainfrom
akshitj11:fix-bsn-enum-subexpression-hoisting
Open

Fix lifetime issues for native subexpressions in bsn! enum variants#24876
akshitj11 wants to merge 1 commit into
bevyengine:mainfrom
akshitj11:fix-bsn-enum-subexpression-hoisting

Conversation

@akshitj11

Copy link
Copy Markdown
Contributor

Summary

bsn! lifts {...} expressions into let _exprN = ... before building SceneFunction closures so they can be 'static. That already worked for plain struct fields via process_field, but not for fields inside enum variant patches like Foo::Baz({expr}), which went through process_enum_field and left the borrow inline in the closure.

This adds the same hoisting branch to process_enum_field.

Fixes #24775

Test plan

  • cargo test -p bevy_scene_macros
  • cargo test -p bevy_scene enum_variant_subexpressions
  • enum_variant_field_values_use_implicit_into still passes
  • cargo fmt on changed crates

Hoist native subexpressions in process_enum_field the same way process_field already does, so SceneFunction closures stay static.
@akshitj11 akshitj11 force-pushed the fix-bsn-enum-subexpression-hoisting branch from 958d16a to 17f52ef Compare July 5, 2026 05:20
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Scenes Composing and serializing ECS objects X-Uncontroversial This work is generally agreed upon D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward D-Macros Code that generates Rust code labels Jul 5, 2026
@alice-i-cecile alice-i-cecile requested a review from cart July 5, 2026 18:58
@alice-i-cecile alice-i-cecile added this to the 0.19.1 milestone Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Scenes Composing and serializing ECS objects C-Bug An unexpected or incorrect behavior D-Macros Code that generates Rust code D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Uncontroversial This work is generally agreed upon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Native subexpressions in bsn! can have lifetime issues

2 participants