You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
False positive for unnecessary_lazy_evaluations #6343
When clippy::unnecessary_lazy_evaluations is on, you get:
warning: unnecessary closure used to substitute value for `Option::None`
--> src/main.rs:3:5
|
3 | Some(&0).and_then(|&i| arr[i].0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Use `and` instead: `Some(&0).and(arr[i].0)`
|
= note: `#[warn(clippy::unnecessary_lazy_evaluations)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
The suggested fix is not well formed because it refers to variable i. A fix should check that the expression in the closure does not depend on any variables in the arguments. (This also arguably isn't a candidate for the lint, because the indexing expression has side effects and a possible computational cost as well.)
Activity
giraffate commentedon Nov 19, 2020
@rustbot modify labels: +L-suggestion-causes-error
giraffate commentedon Nov 20, 2020
I will prepare a fix.
Auto merge of #6370 - giraffate:fix_fp_in_unnecessary_lazy_evaluation…
Auto merge of #6370 - giraffate:fix_fp_in_unnecessary_lazy_evaluation…