Skip to content

suggest a op= b over a = a op b #913

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 2 commits into from
May 11, 2016
Merged

suggest a op= b over a = a op b #913

merged 2 commits into from
May 11, 2016

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented May 11, 2016

since not everyone likes the assign-ops, I also added a restriction lint to forbid assign-ops. Can we somehow make lints depend on each other? like lint if both assign_ops and assign_op_pattern are active?

@llogiq
Copy link
Contributor

llogiq commented May 11, 2016

If they want all the warnings, give them all the warnings 😄

@llogiq
Copy link
Contributor

llogiq commented May 11, 2016

Another thought: Maybe differentiate ops where the assign op is specialized, because those likely improve performance, but may also change behavior.

@oli-obk
Copy link
Contributor Author

oli-obk commented May 11, 2016

Maybe differentiate ops where the assign op is specialized because those likely improve performance

That's what we want

but may also change behavior.

shudder Maybe I should make an RFC that states that the assign ops should be logically equivalent to the full expression. Is there any reason why they shouldn't?

@llogiq
Copy link
Contributor

llogiq commented May 11, 2016

The original RFC that introduced the OpAssign traits already states exactly that. However, it is really hard to guarantee. Someone has probably already written a quickcheck template, though.

@oli-obk
Copy link
Contributor Author

oli-obk commented May 11, 2016

However, it is really hard to guarantee.

we don't need to guarantee it, we can depend on it. If anything, this lint will expose such oddities

@oli-obk
Copy link
Contributor Author

oli-obk commented May 11, 2016

I added your concern to the known problems field of the docs

@llogiq
Copy link
Contributor

llogiq commented May 11, 2016

Couldn't we detect if the type impls Op and avoid reporting otherwise?

@oli-obk
Copy link
Contributor Author

oli-obk commented May 11, 2016

We can, but the point of the restriction is to forbid all assign ops, no matter if there are no alternatives. What I can do is add a lint to detect assign op impls withou an op impl

@llogiq
Copy link
Contributor

llogiq commented May 11, 2016

Ok then. LGTM.

@llogiq llogiq merged commit 8fa68f1 into rust-lang:master May 11, 2016
@oli-obk oli-obk deleted the assign_ops branch May 27, 2016 09:10
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.

2 participants