-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[Arithmetic] Consider literals #9365
Conversation
r? @Alexendoo (rust-highfive has picked a reviewer for you, use r? to override) |
tests/ui/float_arithmetic.rs
Outdated
@@ -1,4 +1,4 @@ | |||
#![warn(clippy::integer_arithmetic, clippy::float_arithmetic)] | |||
#![warn(clippy::arithmetic)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to show that arithmetic
behaves like integer_arithmetic
and float_arithemtic
. Once approved, I will revert this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Just a couple small bits to suggest
Addressed all comments with a new strategy and additional tests |
8f91440
to
871b75f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks!
I think it'd be worth updating the lint documentation to mention that the lint doesn't fire for cases where overflow can't happen
Done |
3a3e315
to
fca2624
Compare
Thanks! @bors r+ Renaming the lint may be a good idea yeah. Could ask on zulip for some input on a potential name, my vote would probably be the slight variation |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Fixes #9307 and makes the
arithmetic
lint behave likeinteger_arithmetic
.It is worth noting that literal integers of a binary operation (
1 + 1
,i32::MAX + 1
), regardless if they are in a constant environment, won't trigger the lint. Assign operations also have similar reasoning.changelog: Consider literals in the arithmetic lint