-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add lint for 'field_reassign_with_default` #568 #4761
Conversation
7cf3338
to
94ce83e
Compare
☔ The latest upstream changes (presumably #4788) made this pull request unmergeable. Please resolve the merge conflicts. |
Thanks for implementing this and sorry for not replying. This went under my radar. Do you think, you could enhance this lint, to also catch more than one assignment. So that let a = Default::default();
a.i = 42;
a.j = 43; suggests let a = A { i: 42, j: 43, ..Default::default() }; |
Ah, yes, sure, doesn't look too difficult. I'm sure I intended it that way but forgot about it somehow. |
☔ The latest upstream changes (presumably #5202) made this pull request unmergeable. Please resolve the merge conflicts. |
Hi @hegza, are you still interested in continuing the PR? As far as I can tell the last suggestion isn't implemented yet; or there's no test case for it at least. Let us know if you need any help =) |
Yeah, sorry, trying to get papers out at work and really having to push it down on the priority list. I'm interested, just busy. |
Thanks for contributing to Clippy! Sadly this PR was not updated in quite some time. If you waited on input from a reviewer, we're sorry that this fell under the radar. If you want to continue to work on this, just reopen the PR and/or ping a reviewer. |
Add lint for 'field_reassign_with_default` #568 changelog: Add lint for field_reassign_with_default that checks if mutable object + field modification is used to edit a binding initialized with Default::default() instead of struct constructor. Fixes #568 Notes: - Checks for reassignment of one or more fields of a binding initialized with Default::default(). - Implemented using EarlyLintPass, might be future proofed better with LateLintPass. - Does not trigger if Default::default() is used via another type implementing Default. - This is a re-open of [PR#4761](#4761), but I couldn't figure out how to re-open that one so here's a new one with the requested changes :S
Add lint for 'field_reassign_with_default` #568 changelog: Add lint for field_reassign_with_default that checks if mutable object + field modification is used to edit a binding initialized with Default::default() instead of struct constructor. Fixes #568 Notes: - Checks for reassignment of one or more fields of a binding initialized with Default::default(). - Implemented using EarlyLintPass, might be future proofed better with LateLintPass. - Does not trigger if Default::default() is used via another type implementing Default. - This is a re-open of [PR#4761](#4761), but I couldn't figure out how to re-open that one so here's a new one with the requested changes :S
changelog: Add lint for
field_reassign_with_default
that checks if mutable object + field modification is used to edit a binding initialized with Default::default() instead of struct constructor.Fixes #568
Notes: