Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make struct_field_names check private fields of public structs. #14076

Merged
merged 2 commits into from
Mar 5, 2025

Conversation

kpreid
Copy link
Contributor

@kpreid kpreid commented Jan 25, 2025

Currently, If a struct is pub and its field is private, and avoid-breaking-exported-api = true (default), then struct_field_names will not lint the field, even though changing the field’s name is not a breaking change. This is because the breaking-exported-api condition was checking the visibility of the struct, not its fields (perhaps because the same code was used for enums). With this change, Clippy will check the field’s effective visibility only.

Note: This change is large because some functions were moved into an impl to be able to access more configuration. Consider viewing the diff with whitespace ignored.

changelog: [struct_field_names]: also check private fields of public structs

@rustbot
Copy link
Collaborator

rustbot commented Jan 25, 2025

r? @Centri3

rustbot has assigned @Centri3.
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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 25, 2025
@kpreid kpreid changed the title Make struct_name_repetitions check private fields of public structs. Make struct_field_names check private fields of public structs. Jan 25, 2025
Copy link
Member

@Centri3 Centri3 left a comment

Choose a reason for hiding this comment

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

Consider viewing the diff with whitespace ignored.

Thanks!

Copy link
Member

@Centri3 Centri3 left a comment

Choose a reason for hiding this comment

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

Thanks !

@Centri3
Copy link
Member

Centri3 commented Feb 16, 2025

Will merge when CI passes

kpreid added 2 commits March 4, 2025 10:49
Currently, If a struct is `pub` and its field is private, and
`avoid-breaking-exported-api = true` (default), then `struct_field_names`
will not lint the field, even though changing the field’s name is not a
breaking change. This is because the breaking-exported-api condition was
checking the visibility of the struct, not its fields (perhaps because
the same code was used for enums). With this change, Clippy will check
 the field’s effective visibility only.

Note: This change is large because some functions were moved into an
`impl` to be able to access more configuration. Consider viewing the
diff with whitespace ignored.
@kpreid
Copy link
Contributor Author

kpreid commented Mar 4, 2025

Will merge when CI passes

Fixed. Sorry for the delay; I understood this comment as “I am going to merge this once a CI run completes” and did not realize that you were telling me that I needed to check on the failures.

@Centri3 Centri3 added this pull request to the merge queue Mar 5, 2025
Merged via the queue into rust-lang:master with commit 231bf45 Mar 5, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

3 participants