Skip to content

Fix missing import in SubStates derive macro (#22892)#22929

Open
Cr0a3 wants to merge 2 commits intobevyengine:mainfrom
Cr0a3:main
Open

Fix missing import in SubStates derive macro (#22892)#22929
Cr0a3 wants to merge 2 commits intobevyengine:mainfrom
Cr0a3:main

Conversation

@Cr0a3
Copy link

@Cr0a3 Cr0a3 commented Feb 12, 2026

Objective

Hello, this pr fixes #22892

Solution

I fixed the 'missing import' bug, by hard coding the import in the code generated by the proc macro.

Testing

The code example given in the issue now compiles fine.

@github-actions
Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added 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 A-States App-level states machines labels Feb 13, 2026
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior X-Uncontroversial This work is generally agreed upon labels Feb 13, 2026
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

CI is complaining about duplicate imports; can you take a look?

@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 13, 2026
@GiantBlargg
Copy link

AFAIK you shouldn't put use in macros, as you don't know what may or may not already be included in the namespace.

You probably want something like:

        impl #impl_generics #state_trait_path for #struct_name #ty_generics #where_clause {
            const DEPENDENCY_DEPTH : usize = <<Self as #trait_path>::SourceStates as #state_set_trait_path>::SET_DEPENDENCY_DEPTH + 1;
        }

@Cr0a3
Copy link
Author

Cr0a3 commented Feb 13, 2026

AFAIK you shouldn't put use in macros, as you don't know what may or may not already be included in the namespace.

You probably want something like:

        impl #impl_generics #state_trait_path for #struct_name #ty_generics #where_clause {
            const DEPENDENCY_DEPTH : usize = <<Self as #trait_path>::SourceStates as #state_set_trait_path>::SET_DEPENDENCY_DEPTH + 1;
        }

Thank you

@Cr0a3
Copy link
Author

Cr0a3 commented Feb 13, 2026

CI is complaining about duplicate imports; can you take a look?

Sure

@Cr0a3
Copy link
Author

Cr0a3 commented Feb 13, 2026

CI is complaining about duplicate imports; can you take a look?

I now fixed the issue with the suggestion being helpful 😁

@kfc35 kfc35 added S-Needs-Review Needs reviewer attention (from anyone!) to move forward and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Feb 13, 2026
@kfc35 kfc35 requested a review from alice-i-cecile February 13, 2026 17:56
Copy link
Contributor

@kfc35 kfc35 left a comment

Choose a reason for hiding this comment

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

Confirmed the provided fix works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-States App-level states machines 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.

SubStates derive macro does not work without trait import

4 participants