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

Respect allow inconsistent_struct_constructor on the struct definition #13211

Conversation

rzvxa
Copy link
Contributor

@rzvxa rzvxa commented Aug 3, 2024

Closes #13203

Now we check if the target type is marked with #[allow(clippy:inconsistent_struct_constructor)] before lining.
As a side-effect of this change, The rule in the subject no longer runs on non-local AdtDefs. However, as suggested by @Jarcho it shouldn't be a big deal since most of the time we didn't have access to this information anyway.

You can't get lint attributes from other crates. I would probably just restrict the lint to only work with types from the current crate while you're at it. Upstream crates don't have a definition order from the point of view of the current crate (with the exception of #[repr(C)] structs).

changelog: Respect allow inconsistent_struct_constructor on the struct definition.

@rustbot
Copy link
Collaborator

rustbot commented Aug 3, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Alexendoo (or someone else) some time within the next two weeks.

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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 3, 2024
@rzvxa rzvxa marked this pull request as ready for review August 3, 2024 19:44
@rzvxa
Copy link
Contributor Author

rzvxa commented Aug 5, 2024

@Alexendoo It would be awesome if we get reviews on this somewhere before the next release; We'd love to see this in the upcoming version of Clippy, It allows us to skip writing a bunch of temporary constructors.

On the other hand; If it is rejected, knowing it will help us start developing alternative approaches through builder methods.

@Jarcho
Copy link
Contributor

Jarcho commented Aug 6, 2024

This won't land until at least 1.82. We follow the same nightly->beta->stable release process that rust does. Next beta cutoff is at the beginning of September, so plenty of time.

@rzvxa
Copy link
Contributor Author

rzvxa commented Aug 6, 2024

This won't land until at least 1.82. We follow the same nightly->beta->stable release process that rust does. Next beta cutoff is at the beginning of September, so plenty of time.

Oh, I thought September was the stable cutoff that's why I was trying to push the review to an earlier date. Thanks for informing me mate, You've been really helpful to me in the past few days. I appreciate it.

Comment on lines 75 to 77
&& let Some(local_def_id) = adt_def.did().as_local()
&& let ty_hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id)
&& !is_lint_allowed(cx, INCONSISTENT_STRUCT_CONSTRUCTOR, ty_hir_id)
Copy link
Member

Choose a reason for hiding this comment

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

This can use fulfill_or_allow just before the span_lint_and_sugg so that #[expect] also works

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I've missed this review in my notifications, Pushed a patch addressing this change request.
@rustbot review

@Alexendoo Alexendoo added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Aug 8, 2024
@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 Aug 9, 2024
@Alexendoo
Copy link
Member

Thank you!

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 9, 2024

📌 Commit d85cf0b has been approved by Alexendoo

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Aug 9, 2024

⌛ Testing commit d85cf0b with merge 1c81105...

@bors
Copy link
Collaborator

bors commented Aug 9, 2024

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Alexendoo
Pushing 1c81105 to master...

@bors bors merged commit 1c81105 into rust-lang:master Aug 9, 2024
8 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.

Respect #[allow(clippy::inconsistent_struct_constructor)] on adt definition.
5 participants