Skip to content

Add new lints: [method_shadow_field, method_shadow_public_field]#16785

Open
raydroplet wants to merge 2 commits into
rust-lang:masterfrom
raydroplet:method_shadow_field
Open

Add new lints: [method_shadow_field, method_shadow_public_field]#16785
raydroplet wants to merge 2 commits into
rust-lang:masterfrom
raydroplet:method_shadow_field

Conversation

@raydroplet
Copy link
Copy Markdown

@raydroplet raydroplet commented Mar 30, 2026

Closes #1481

This is my first pull request. It implements the two lints suggested in the original thread.
The dogfood test was not passing, so I added an allow clause. It may be worth taking a look.

changelog: Add new lints [method_shadow_field] and [method_shadow_public_field] that warn when a method name shadows a struct or union field

@rustbot rustbot added needs-fcp PRs that add, remove, or rename lints and need an FCP S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Mar 30, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 30, 2026

r? @llogiq

rustbot has assigned @llogiq.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 30, 2026

Lintcheck changes for 364f24b

Lint Added Removed Changed
clippy::method_shadow_field 1246 0 0
clippy::method_shadow_public_field 53 0 0

This comment will be updated if you push new changes

Copy link
Copy Markdown
Contributor

@llogiq llogiq left a comment

Choose a reason for hiding this comment

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

I think the most salient thing is avoiding breaking public API. Otherwise I'd like to see more interaction tests (no matter whether they are linted or not – those tests document the limits of the lint).

View changes since this review

Comment thread clippy_lints/src/method_shadow_field.rs Outdated
Comment thread clippy_lints/src/method_shadow_field.rs Outdated
Comment thread tests/ui/method_shadow_field.rs
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Apr 4, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 4, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) label Apr 4, 2026
@raydroplet
Copy link
Copy Markdown
Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Apr 11, 2026
@rustbot

This comment has been minimized.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 14, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Apr 14, 2026
@raydroplet raydroplet force-pushed the method_shadow_field branch from b17996b to 364f24b Compare April 14, 2026 17:03
@rustbot rustbot removed has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Apr 14, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 15, 2026

☔ The latest upstream changes (possibly #16770) made this pull request unmergeable. Please resolve the merge conflicts.

@raydroplet
Copy link
Copy Markdown
Author

@rustbot r? clippy

@rustbot rustbot assigned flip1995 and unassigned llogiq May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-fcp PRs that add, remove, or rename lints and need an FCP S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lint on method/struct fields sharing the same name

4 participants