Open
Description
Code reduced from my actual project:
fn main() {
let f = |_| true;
while Some(1).map_or(false, |x| f(x)) {}
}
Clippy:
warning: redundant closure found
--> src/main.rs:3:33
|
3 | while Some(1).map_or(false, |x| f(x)) {}
| ^^^^^^^^
|
= note: #[warn(redundant_closure)] on by default
help: remove closure as shown:
| while Some(1).map_or(false, f) {}
= help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#redundant_closure
Clippy's suggestion doesn't compile:
error[E0382]: use of moved value: `f`
--> src/main.rs:3:33
|
3 | while Some(1).map_or(false, f) {}
| ^ value moved here in previous iteration of loop
|
= note: move occurs because `f` has type `[closure@src/main.rs:2:13: 2:21]`, which does not implement the `Copy` trait
error: aborting due to previous error
$ rustc -V
rustc 1.17.0-nightly (b1e31766d 2017-03-03)
$ cargo clippy -V
0.0.118