Skip to content

require produces an erroneous lint #25612

Description

@mnmaita

Bevy version and features

  • 0.19.x

What you did

Using avian2d I noticed that adding CollisionLayers as a required component can cause clippy to report a lint if the collision layers (memberships and filters) are the same:

#[derive(Component, Default, Clone)]
#[require(
    CollisionLayers::new(CollisionLayer::Layer1, CollisionLayer::Layer1),
)]
pub struct MyComponent;

CollisionLayer is an enum with several variants and derives Avian's PhysicsLayer. And, to add some extra context, CollisionLayers::new(CollisionLayer::Layer1, CollisionLayer::Layer1) means the entity will be a member of collision layer Layer1 and will collide with other members of Layer2. This is something valid and has nothing to do with duplicated attributes.

What went wrong

Here's the lint/warning, which suggests to "remove the duplicate attribute":

duplicated attribute
for further information visit https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#duplicated_attributes
`#[warn(clippy::duplicated_attributes)]`

This doesn't happen when adding the component to spawn or spawn_scene calls, which makes me think there might be an issue with the require attribute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorD-MacrosCode that generates Rust codeD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    Projects

    • Status
      Needs SME Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions