Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insert_unit_bundle lint diagnostic cannot find expression of unit if created outside Commands::spawn() #248

Open
BD103 opened this issue Jan 28, 2025 · 0 comments
Labels
A-Linter Related to the linter and custom lints C-Bug A bug in the program D-Complex Quite challenging from either a design or technical perspective. Ask for help!

Comments

@BD103
Copy link
Member

BD103 commented Jan 28, 2025

#![feature(register_tool)]
#![register_tool(bevy)]
#![deny(bevy::insert_unit_bundle)]

use bevy::prelude::*;

fn my_system(mut commands: Commands) {
    // Error emitted here:
    commands.spawn(bundle());
    //             ^^^^^^^^
}

fn bundle() -> (Name, ()) {
    // Error should be emitted here:
    (Name::new("Foo"), ())
    //                 ^^
}

insert_unit_bundle expects the tuple bundle to be created inside of Commands::spawn(). If it is created outside, it will not recurse into the expression to find the erroneous unit ().

@BD103 BD103 added A-Linter Related to the linter and custom lints C-Bug A bug in the program D-Complex Quite challenging from either a design or technical perspective. Ask for help! labels Jan 28, 2025
BD103 added a commit that referenced this issue Jan 28, 2025
…s not found

This is actually a common code path, as described by #248.
@BD103 BD103 changed the title insert_unit_bundle lint cannot find expression of unit if created outside Commands::spawn() insert_unit_bundle lint diagnostic cannot find expression of unit if created outside Commands::spawn() Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Related to the linter and custom lints C-Bug A bug in the program D-Complex Quite challenging from either a design or technical perspective. Ask for help!
Projects
None yet
Development

No branches or pull requests

1 participant