WIP: lint for the use of operator trait methods #6433
Closed
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.
Fixes #6286
This implements a lint for the operator traits (except
Deref
andDerefMut
as discussed in the issue). This implementation is mostly working. There are a few points where I would like to get some feedback or support for:Example with warnings and logs:
The rust code:
Lint output:
The fixme log from the CI:
a.bitxor(b)
can be seen as more readable thana ^ b
. Having a setting could enable the user to specify which method uses should be linted and which not.Deref
andDerefMut
.std::cmp::*
traits likePartialOrd
with the current structure. Should I maybe add support for them under a different lint name in this PR as well? 🙃It has been fun working on this project and I'm impressed by the awesome util functions that are available. Thank you for the nice structure of the crate! 🙃
changelog: Added a lint for the use of operator trait methods (
use_of_operator_trait_method
)