Skip to content

Fix Constructor derive emitting redundant_field_names lint - #560

Open
akundaz wants to merge 1 commit into
JelteF:masterfrom
akundaz:fix/constructor-redundant-field-names
Open

Fix Constructor derive emitting redundant_field_names lint#560
akundaz wants to merge 1 commit into
JelteF:masterfrom
akundaz:fix/constructor-redundant-field-names

Conversation

@akundaz

@akundaz akundaz commented Aug 12, 2026

Copy link
Copy Markdown

The Constructor derive for named-field structs was generating:

Self { field: field }

instead of the field init shorthand:

Self { field }

This triggers clippy::redundant_field_names on nightly Clippy when -D warnings is set, breaking crates that use #[deny(clippy::all)] or similar.

Fix: use #(#field_names),* in the struct literal rather than #(#field_names: #vars),*. Since the parameter names already match the field names, the shorthand is always valid here. This also removes a redundant variable alias and clone in struct_body.

@akundaz

akundaz commented Aug 12, 2026

Copy link
Copy Markdown
Author

The CI failure (compile_fail) seems to be pre-existing and unrelated to this change. I can reproduce it locally on master without my commit applied — 4 of 136 compile_fail tests fail there too.

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.

1 participant