2019-04-22 08:40:08 +01:00
|
|
|
error[E0507]: cannot move out of captured variable in an `FnMut` closure
|
|
|
|
--> $DIR/issue-4335.rs:6:20
|
|
|
|
|
|
2019-05-28 14:46:13 -04:00
|
|
|
LL | fn f<'r, T>(v: &'r T) -> Box<dyn FnMut() -> T + 'r> {
|
2019-04-22 08:40:08 +01:00
|
|
|
| - captured outer variable
|
|
|
|
LL | id(Box::new(|| *v))
|
|
|
|
| ^^ cannot move out of captured variable in an `FnMut` closure
|
|
|
|
|
2017-12-10 22:47:55 +03:00
|
|
|
error[E0373]: closure may outlive the current function, but it borrows `v`, which is owned by the current function
|
2018-12-25 08:56:47 -07:00
|
|
|
--> $DIR/issue-4335.rs:6:17
|
2017-12-10 22:47:55 +03:00
|
|
|
|
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | id(Box::new(|| *v))
|
2017-12-10 22:47:55 +03:00
|
|
|
| ^^ - `v` is borrowed here
|
|
|
|
| |
|
|
|
|
| may outlive borrowed value `v`
|
2019-04-22 08:40:08 +01:00
|
|
|
|
|
|
|
|
note: closure is returned here
|
|
|
|
--> $DIR/issue-4335.rs:6:5
|
|
|
|
|
|
|
|
|
LL | id(Box::new(|| *v))
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^
|
2017-12-10 22:47:55 +03:00
|
|
|
help: to force the closure to take ownership of `v` (and any other referenced variables), use the `move` keyword
|
|
|
|
|
|
2018-02-25 02:01:39 +03:00
|
|
|
LL | id(Box::new(move || *v))
|
2017-12-10 22:47:55 +03:00
|
|
|
| ^^^^^^^
|
|
|
|
|
|
|
|
error: aborting due to 2 previous errors
|
|
|
|
|
2019-04-17 13:26:38 -04:00
|
|
|
Some errors have detailed explanations: E0373, E0507.
|
2018-03-03 15:59:40 +01:00
|
|
|
For more information about an error, try `rustc --explain E0373`.
|