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 calculating remainder with divisor of -1 #6321

Closed
mlegner opened this issue Nov 11, 2020 · 3 comments · Fixed by #6360
Closed

Lint for calculating remainder with divisor of -1 #6321

mlegner opened this issue Nov 11, 2020 · 3 comments · Fixed by #6360
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages

Comments

@mlegner
Copy link
Contributor

mlegner commented Nov 11, 2020

While for remainder with 1 there is the modulo_one lint, a remainder with -1 is only caught by the integer_arithmetic lint, which is disabled by default (playground). The issue has been discussed briefly in #663 but not resolved.

As there are only two possible outcomes when calculating the remainder with -1 (overflow/panic or 0), this should definitely be linted in my opinion. I suggest modifying the modulo_one lint to also be triggered by -1 (potentially with a different warning).

@giraffate
Copy link
Contributor

@rustbot modify labels: +L-enhancement

@rustbot rustbot added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Nov 11, 2020
@mlegner
Copy link
Contributor Author

mlegner commented Nov 12, 2020

If maintainers agree that this is worthwhile, I'm happy to create a PR.

@camsteffen
Copy link
Contributor

I'm not a maintainer but I say go for it. The -1 case is very similar to the 1 case in terms of uselessness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants