Closed
Description
struct NotCopyable;
fn func<F: FnMut() -> H, H: FnMut()>(_: F) {}
fn parse() {
let mut var = None;
func(|| {
move || {
var = Some(NotCopyable);
}
});
}
gives the error:
error[E0507]: cannot move out of `var`, a captured variable in an `FnMut` closure
--> src/lib.rs:8:9
|
6 | let mut var= None;
| --------- captured outer variable
7 | func(|| {
8 | move || {
| ^^^^^^^
| |
| move out of `var` occurs here
| help: consider borrowing the `Option`'s content: `move ||.as_ref()`
9 | var = Some(NotCopyable);
| -----
| |
| move occurs because `var` has type `std::option::Option<NotCopyable>`, which does not implement the `Copy` trait
| move occurs due to use in closure
Error0507 gives a wrong suggestion here:
help: consider borrowing the `Option`'s content: `move ||.as_ref()`