Skip to content

Silence clippy::redundant_field_names in derive(Query) output - #482

Merged
Ralith merged 2 commits into
Ralith:masterfrom
qwist1233-cpu:fix-redundant-field-names
Nov 11, 2026
Merged

Ralith merged 2 commits into
Ralith:masterfrom
qwist1233-cpu:fix-redundant-field-names

Conversation

@qwist1233-cpu

Copy link
Copy Markdown
Contributor

derive(Query) emits Query::get as

let transform: <&Transform as Query>::Item<'q> = <&Transform as Query>::get(meta, &fetch.transform, n);
// ...
DamageEntity { transform: transform, body: body, source: source }

The intermediate bindings are named after the fields they initialize, so every field of a
#[derive(Query)] struct — and every field of a derived enum's variants — fires
clippy::redundant_field_names. The diagnostic points at the user's own field declarations,
so a downstream crate cannot address it except by putting an allow on each query type.

This adds the lint to the #[allow(...)] that already sits on both generated get
implementations (struct and enum). No change to the generated logic.

Verification

The struct from the issue, plus an enum query, compiled against this branch and against
master with cargo clippy on stable (run log):

macros/src/query.rs from redundant field names warnings
master 6
this branch 0

cargo test -p hecs --features macros in the same run: 32 passed, 0 failed.

Closes #481

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q9q9u6LVGiugiXESP56EQK

The generated `Query::get` builds the item struct from intermediate
bindings named after the fields they initialize, so every field of a
`#[derive(Query)]` struct or enum variant triggers
`clippy::redundant_field_names` in the user's crate, where the lint
cannot be addressed.

Closes Ralith#481

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q9q9u6LVGiugiXESP56EQK
Signed-off-by: qwist1233-cpu <[email protected]>

@Ralith Ralith left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks! Please drop the comments; this is pretty self-explanatory in context.

Another option would be to generate the code clippy would prefer, but only if that code would be at most as complex as the status quo; better to allow the lint than to make the macro harder to maintain.

@qwist1233-cpu

Copy link
Copy Markdown
Contributor Author

Done — dropped the comments, the diff is now just the two allow attributes.

@Ralith
Ralith enabled auto-merge (squash) November 11, 2026 18:27
@Ralith
Ralith merged commit d0816c9 into Ralith:master Nov 11, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#[derive(Query)] causes clippy::redundant_field_names after a Rust upgrade

2 participants