Skip to content

Do not trigger unused_assignments for overloaded AssignOps #32048

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

Merged
merged 3 commits into from
Mar 6, 2016

Conversation

bluss
Copy link
Member

@bluss bluss commented Mar 4, 2016

Do not trigger unused_assignments for overloaded AssignOps

If v were a type with some kind of indirection, so that v += 1 would
have an effect even if v were not used anymore, the unused_assignments lint
would mark a false positive.

This exempts overloaded (non-primitive) assign ops from being treated as
assignments (they are method calls).

The previous compile-fail tests that ensure x += 1 can trigger for
primitive types continue to pass. Added a representative test for the
"view" indirection.

Fixes #31895

If `v` were a type with some kind of indirection, so that `v += 1` would
have an effect even if `v` were not used anymore, the unused_assignments lint
would mark a false positive.

This exempts overloaded (non-primitive) assign ops from being treated as
assignments (they are method calls).

The previous compile-fail tests that ensure x += 1 can trigger for
primitive types continue to pass. Added a representative test for the
"view" indirection.
@bluss
Copy link
Member Author

bluss commented Mar 4, 2016

Thanks to @eddyb for the basically pointing out exactly what to do.

@bluss bluss force-pushed the overloaded-assign-op branch from 357e2f7 to d5b6599 Compare March 4, 2016 20:47
@eddyb
Copy link
Member

eddyb commented Mar 4, 2016

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 4, 2016

📌 Commit d5b6599 has been approved by eddyb

@bluss
Copy link
Member Author

bluss commented Mar 4, 2016

This is one warning down. I discovered that the testcase in bug #31895 still has this one too:

:14:13: 14:18 warning: variable `b` is assigned to, but never used, 

…dAssign

Visit an overloaded += like a method call and not like an assignment.
@eddyb
Copy link
Member

eddyb commented Mar 4, 2016

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 4, 2016

📌 Commit cfe4efd has been approved by eddyb

bors added a commit that referenced this pull request Mar 6, 2016
Do not trigger unused_assignments for overloaded AssignOps

If `v` were a type with some kind of indirection, so that `v += 1` would
have an effect even if `v` were not used anymore, the unused_assignments lint
would mark a false positive.

This exempts overloaded (non-primitive) assign ops from being treated as
assignments (they are method calls).

The previous compile-fail tests that ensure x += 1 can trigger for
primitive types continue to pass. Added a representative test for the
"view" indirection.

Fixes #31895
@bors
Copy link
Collaborator

bors commented Mar 6, 2016

⌛ Testing commit cfe4efd with merge 71f4658...

@bors bors merged commit cfe4efd into rust-lang:master Mar 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants