Duration's constructors should not trigger or_fun_call #7483
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
Lint name: or_fun_call
I tried this code:
I expected to see this happen: nothing, since
Duration::from_secs
is a const fn. it's cheaper to useunwrap_or
thanunwrap_or_else
, which requires creating a closure. I understand the rationale for closing #6943: Clippy can't be certain that the function will be evaluated at compile time. However, I would argue that since Clippy can neither be certain that the function will be evaluated at runtime, it should not make a recommendation one way or the other in this case. This is a case where the programmer probably knows more than Clippy does.Instead, this happened:
Meta
cargo clippy -V
:e.g. clippy 0.0.212 (f455e46 2020-06-20)
rustc -Vv
:The text was updated successfully, but these errors were encountered: