Skip to content

Warn on redundant update #10476

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

Closed
ndmitchell opened this issue Mar 10, 2023 · 3 comments · Fixed by #10489
Closed

Warn on redundant update #10476

ndmitchell opened this issue Mar 10, 2023 · 3 comments · Fixed by #10489
Assignees
Labels
A-lint Area: New lints

Comments

@ndmitchell
Copy link

ndmitchell commented Mar 10, 2023

What it does

If your update changes no fields, e.g. MyRecord {..value} then the update is providing very little value, and value directly would be better.

Lint Name

redundant_update

Category

style

Advantage

  • Simpler.

Drawbacks

No response

Example

MyRecord { ..value}

Could be written as:

value
@ndmitchell ndmitchell added the A-lint Area: New lints label Mar 10, 2023
@samueltardieu
Copy link
Contributor

Are they really equivalent? MyRecord { ..value } moves value unless it implements Copy, so wouldn't MyRecord { ..value } be equivalent to value, and not value.clone()?

@ndmitchell
Copy link
Author

@samueltardieu great point - thanks - that makes it an even better hint. I've edited the initial description to incorporate your observation.

@samueltardieu
Copy link
Contributor

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants