2020-05-20 12:58:41 -05:00
|
|
|
error: captured variable cannot escape `FnMut` closure body
|
2018-12-25 09:56:47 -06:00
|
|
|
--> $DIR/regions-return-ref-to-upvar-issue-17403.rs:7:24
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2020-05-23 20:40:55 -05:00
|
|
|
LL | let mut x = 0;
|
|
|
|
| ----- variable defined here
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | let mut f = || &mut x;
|
2020-05-23 20:40:55 -05:00
|
|
|
| - ^^^^^-
|
|
|
|
| | | |
|
|
|
|
| | | variable captured here
|
|
|
|
| | returns a reference to a captured variable which escapes the closure body
|
2020-05-20 12:58:41 -05:00
|
|
|
| inferred to be a `FnMut` closure
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2020-05-20 12:58:41 -05:00
|
|
|
= note: `FnMut` closures only have access to their captured variables while they are executing...
|
|
|
|
= note: ...therefore, they cannot allow references to captured variables to escape
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error: aborting due to previous error
|
|
|
|
|