Add new lint [unused_rounding]#8866
Conversation
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @llogiq (or someone else) soon. Please see the contribution instructions for more information. |
| } else { | ||
| "" | ||
| }; | ||
| if f.fract() < f64::EPSILON { |
There was a problem hiding this comment.
Is the test that f is a whole number? f64::EPSILON is 2-53 but it's possible for a positive float to be smaller than that. Try let _ = 2E-54f64.floor(); in your tests.
There was a problem hiding this comment.
You're right. Thanks! This should be fixed now
| #[clippy::version = "1.62.0"] | ||
| pub UNUSED_ROUNDING, | ||
| nursery, | ||
| "Rounding a whole number literal, which is useless" |
There was a problem hiding this comment.
| "Rounding a whole number literal, which is useless" | |
| "Uselessly rounding a whole number floating-point literal" |
|
@llogiq I made both changes. I'm not sure about omitting it in tests, so I left that the same for now. What would be the reason for doing that? |
|
☔ The latest upstream changes (presumably #8882) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Ah shoot, I messed up with the rebase, didn't I? |
ed20458 to
ec3fdd6
Compare
ec3fdd6 to
f489954
Compare
|
Thank you! @bors r+ |
|
📌 Commit f489954 has been approved by |
|
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
fixes #39
changelog: added a
[`unused_rounding`]lint to check for the rounding of whole-number literals