Skip to content

Fix: Add turbofish support to bsn!#25054

Open
Tatsuya0330 wants to merge 3 commits into
bevyengine:mainfrom
Tatsuya0330:issue_24962
Open

Fix: Add turbofish support to bsn!#25054
Tatsuya0330 wants to merge 3 commits into
bevyengine:mainfrom
Tatsuya0330:issue_24962

Conversation

@Tatsuya0330

@Tatsuya0330 Tatsuya0330 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Objective

Background

  • Previously, when calling a template constructor within the bsn! with turbofish syntax, the generic type arguments were completely omitted upon macro expansion.
  • This happened because TemplateConstructor and FromTemplateConstructor did not possess any variables or fields designated to receive and output those type arguments.

Solution

crates/bevy_scene/macros/src/bsn/types.rs

  • Added a pub function_generics: Option<syn::AngleBracketedGenericArguments> field to the BsnConstructor struct.

crates/bevy_scene/macros/src/bsn/parse.rs

  • I extended take_last_path_ident and introduced a new function.
    • take_last_path_segment: which retrieves a syn::PathSegment containing both the identifier and the arguments.
  • During the parsing of PathType::TypeFunction, the generic arguments enclosed in angle brackets following the method name are now extracted.
    • Stored in a newly added field, function_generics, within BsnConstructor.

crates/bevy_scene/macros/src/bsn/codegen.rs

  • Added logic to expand the extracted function_generics as a turbofish immediately after the method name during token generation for TemplateConstructor and FromTemplateConstructor.

Testing

Added unit test

  • Verified that the turbofish is correctly token-expanded in TemplateConstructor and FromTemplateConstructor.

@kfc35 kfc35 added C-Bug An unexpected or incorrect behavior A-Scenes Composing and serializing ECS objects S-Needs-Review Needs reviewer attention (from anyone!) to move forward D-Macros Code that generates Rust code labels Jul 18, 2026
@alice-i-cecile alice-i-cecile added X-Uncontroversial This work is generally agreed upon D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Jul 18, 2026
@alice-i-cecile
alice-i-cecile requested review from cart and laundmo and removed request for cart July 18, 2026 17:53
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-Straightforward Simple bug fixes and API improvements, docs, test and examples 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.

Turbofish is not supported in bsn!

3 participants