unnecessary_lazy_evaluations
fix causes a panic when used with Range::contains()
#11930
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Summary
I encountered this error during Advent of Code where Clippy suggests to change an
Option::then
tothen_some
. I usedstd::ops::Range::contains()
to make sure the closure passed tothen
is safe to call. It can panic when the number is not within the range and should not be evaluated eagerly.I'm not sure if a lint like this could possibly take outside context into account but it's a false positive nonetheless.
Lint Name
unnecessary_lazy_evaluations
Reproducer
The version with
then
works as expected.
The version with
then_some
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: