-
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
suggest struct constructor instead of mutable object + field mod #568
Labels
A-lint
Area: New lints
good-first-issue
These issues are a good way to get started with Clippy
T-AST
Type: Requires working with the AST
Comments
Manishearth
added
good-first-issue
These issues are a good way to get started with Clippy
T-AST
Type: Requires working with the AST
A-lint
Area: New lints
labels
Jan 20, 2016
hegza
pushed a commit
to hegza/rust-clippy
that referenced
this issue
Oct 31, 2020
- Implement `field_reassign_with_default` as a `LateLintPass` - Avoid triggering `default_trait_access` on a span already linted by `field_reassigned_with_default` - Co-authored-by: Eduardo Broto <[email protected]> - Fixes rust-lang#568
bors
added a commit
that referenced
this issue
Nov 4, 2020
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
bors
added a commit
that referenced
this issue
Nov 4, 2020
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
Ryan1729
pushed a commit
to Ryan1729/rust-clippy
that referenced
this issue
Nov 7, 2020
- Implement `field_reassign_with_default` as a `LateLintPass` - Avoid triggering `default_trait_access` on a span already linted by `field_reassigned_with_default` - Merge `default_trait_access` and `field_reassign_with_default` into `Default` - Co-authored-by: Eduardo Broto <[email protected]> - Fixes rust-lang#568
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-lint
Area: New lints
good-first-issue
These issues are a good way to get started with Clippy
T-AST
Type: Requires working with the AST
If you have a struct where all fields are public, then you should never do
let mut a = A::default(); a.x = 42;
but instead use a constructor with.. A::default()
at the end:The text was updated successfully, but these errors were encountered: