`require` produces an erroneous lint
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## 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:
```rust
#[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":
```shell
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.
Contributor guide
Research direction
Reproduce the warning with the shown `#[require]` attribute and compare it with equivalent components added through `spawn` or `spawn_scene`. Trace the `require` attribute handling and verify that valid membership and filter values no longer trigger `clippy::duplicated_attributes`, while genuinely duplicated attributes still do.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100