Skip to content
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

Lint for suspicious implementations of arithmetic std::ops traits #2458

Merged
merged 2 commits into from
Feb 20, 2018

Conversation

flip1995
Copy link
Member

This addresses Issue #2268 .

It lints for implementations of arithmetic operations and OpAssign implementations.

Currently it only lints for the arithmetic operations Add, Sub, Mul, Div. Other traits of binary operations can be easily added though.

Regarding the OpAssign implementations, it lints for every possible OpAssign trait. If you implement OpAssign, you probably have implemented Op already, so that the implementation is a one-liner.

If there are multiple binary operations in an expression (e.g. (a + b) % 10), it will not lint.

@oli-obk oli-obk merged commit a149ec4 into rust-lang:master Feb 20, 2018
@flip1995 flip1995 deleted the suspicious_impl branch March 7, 2018 14:12
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