-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
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
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied