2019-09-06 13:47:50 +00:00
|
|
|
error: captured variable cannot escape `FnMut` closure body
|
|
|
|
--> $DIR/issue-49824.rs:4:9
|
2019-04-22 07:40:08 +00:00
|
|
|
|
|
2020-05-24 01:40:55 +00:00
|
|
|
LL | let mut x = 0;
|
|
|
|
| ----- variable defined here
|
2019-04-22 07:40:08 +00:00
|
|
|
LL | || {
|
|
|
|
| - inferred to be a `FnMut` closure
|
|
|
|
LL | / || {
|
|
|
|
LL | |
|
|
|
|
LL | | let _y = &mut x;
|
2020-05-24 01:40:55 +00:00
|
|
|
| | - variable captured here
|
2019-04-22 07:40:08 +00:00
|
|
|
LL | | }
|
|
|
|
| |_________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body
|
|
|
|
|
|
|
|
|
= 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
|
2022-07-22 16:53:39 +00:00
|
|
|
help: consider adding 'move' keyword before the nested closure
|
|
|
|
|
|
|
|
|
LL | move || {
|
|
|
|
| ++++
|
2018-07-27 22:09:23 +00:00
|
|
|
|
2023-11-21 15:44:16 +00:00
|
|
|
error: aborting due to 1 previous error
|
2018-07-27 22:09:23 +00:00
|
|
|
|