Skip to content

fix: skip redundant_field_names lint on macro-generated code - #17526

Closed
waterWang wants to merge 3 commits into
rust-lang:masterfrom
waterWang:fix/redundant-field-names-macro
Closed

fix: skip redundant_field_names lint on macro-generated code#17526
waterWang wants to merge 3 commits into
rust-lang:masterfrom
waterWang:fix/redundant-field-names-macro

Conversation

@waterWang

@waterWang waterWang commented Aug 8, 2026

Copy link
Copy Markdown

Fixes #17525

redundant_field_names was firing on code generated by proc-macro derives (e.g., thiserror::Error), where the user cannot control the generated expansion. This adds a !field.span.from_expansion() guard to skip linting any code from macro expansions, including proc-macro derive output.

Changes

  • clippy_lints/src/redundant_field_names.rs: added && !field.span.from_expansion() check
  • tests/ui/redundant_field_names.rs: removed internal! macro lint expectation (now skipped by from_expansion() check)
  • tests/ui/redundant_field_names.stderr: updated expected error count from 9 to 8

@rustbot rustbot added S-waiting-on-community-reviews Status: This is awaiting for positive reviews from the community before a maintainer is assigned. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Aug 8, 2026
@rustbot

rustbot commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome!

You should hear from one of our reviewers after this PR gets at least 2 reviews from the community.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@jieyouxu

jieyouxu commented Aug 9, 2026

Copy link
Copy Markdown
Member

Moderation note: user was suspended due to automated contributions (cf. rust-lang/rust#160788).

@blyxyas

blyxyas commented Aug 10, 2026

Copy link
Copy Markdown
Member

Hello @waterWang, seems that your account is automated (probably authored by some agent).
We are closing this pull request to leave easy first issues to new contributors.

Thanks for the warning, @jieyouxu!

@blyxyas blyxyas closed this Aug 10, 2026
@rustbot rustbot removed S-waiting-on-community-reviews Status: This is awaiting for positive reviews from the community before a maintainer is assigned. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Aug 10, 2026
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.

redundant_field_names triggered on derived code

4 participants