Skip to content

#[entities] should error when put on a enum variant #19346

@mirsella

Description

@mirsella

hello !

Bevy version

bevy 0.16.0

If your bug is rendering-related, copy the adapter info that appears when you run Bevy.

What you did

#[derive(Component)]
pub enum TroopState {
    Idle,
    #[entities] // should error
    Run(Option<Target>),
    #[entities] // should error
    Attack(Target),
}
#[derive(Component)]
pub struct Target {
    #[entities]
    pub entity: Entity,
}

Target is not mapped, this is a footgun, without any warning

What went wrong

the #[entities] should be on the associated type like so Run(#[entities] Option<Target>)
maybe the derive macro can error when the annotation is on the enum variant instead of actual type ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorD-MacrosCode that generates Rust codeS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed upon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions