-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
unnecessary_lazy_evaluations
suggestion causes panic on bool::then
#9422
Comments
I was hit by this bug as well. |
It also suggests to use |
What's the status of this? Any aim to fix this in future release? The fact that clippy auto-fixes this makes this especially problematic--any auto fix should be guaranteed to be a functional no-op, which is not the case here |
…ons lint Otherwise, this panics when `id` is 0. This is a known false positive in clippy (rust-lang/rust-clippy#9422).
This is more general than x.checked_sub(y).unwrap_or_else(|| y - x) // correct but linted
x.checked_sub(y).unwrap_or(y - x) // incorrect suggested fix |
The code that clippy uses for figuring out if a closure is necessary or not is shared between all of these lints, so a fix to |
Summary
Clippy does not consider the possibility of arithmetic underflow in the non-lazy suggestion
Lint Name
unnecessary_lazy_evaluations
Reproducer
clippy output:
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: