Lint for suspicious implementations of arithmetic std::ops traits #2458
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 possibleOpAssign
trait. If you implementOpAssign
, you probably have implementedOp
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.