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