-
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
unneeded_field_pattern #1741
Comments
I've not been totally happy with this lint either and would be fine with moving this to allow-by-default, and only have it warn when We definitely need the opposite lint as a restriction lint for safety minded projects to never ever use |
👍 |
I also ran into this, and tried to made a case here: #4253: I is not clear that:
This lint helps users discover that The only place where I see no serious drawback of using |
I also think that this lint doesn't serve a good purpose. It is an advantage of the language that one must explicitly list all fields of a struct when destructuring. It allows the compiler to help identify all sites in the code that ought to be reconsidered when adding a new field to a struct. That gives more correctness confidence when modifying existing structures and code, which is very much in the spirit of Rust.
|
Often times we want to explicty destructure instead of using .. because the compiler will emit errors if the structure changes. (see rust-lang/rust-clippy#1741 and #69)
This should definitely become allow-by-default. |
I went ahead and created #5200 5200 to execute this |
Move unneeded_field_pattern to restriction group Fixes #1741 changelog: Move unneeded_field_pattern to pedantic group
Move unneeded_field_pattern to restriction group Fixes #1741 changelog: Move unneeded_field_pattern to pedantic group
Move unneeded_field_pattern to restriction group Fixes #1741 changelog: Move unneeded_field_pattern to pedantic group
Move unneeded_field_pattern to restriction group Fixes #1741 changelog: Move unneeded_field_pattern to pedantic group
Here is an an exact warning from our code. We have a large codebase (several tens of thousands of lines) and get a lot of refactor value out of having a complete destructure without .. syntax.
When we use {..} it increases the probability that someone changes the fields of UpdateHiddenStateReq and forgets to change the usage site here.
One of rust's biggest advantages for us is how it prevents us from shooting ourselves in the foot during refactors or edits in situations like this.
Now I understand that not everyone has this concern and the .. syntax definitely has its benefits, but I do think it's worth discussing if this should be a warning. What do you think?
Thanks
The text was updated successfully, but these errors were encountered: