File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
src/librustc_error_codes/error_codes Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 1- This error occurs when an attempt is made to use data captured by a closure,
2- when that data may no longer exist. It's most commonly seen when attempting to
3- return a closure :
1+ A captured variable in a closure may not live long enough.
2+
3+ Erroneous code example :
44
55``` compile_fail,E0373
66fn foo() -> Box<Fn(u32) -> u32> {
@@ -9,6 +9,10 @@ fn foo() -> Box<Fn(u32) -> u32> {
99}
1010```
1111
12+ This error occurs when an attempt is made to use data captured by a closure,
13+ when that data may no longer exist. It's most commonly seen when attempting to
14+ return a closure as shown in the previous code example.
15+
1216Notice that ` x ` is stack-allocated by ` foo() ` . By default, Rust captures
1317closed-over data by reference. This means that once ` foo() ` returns, ` x ` no
1418longer exists. An attempt to access ` x ` within the closure would thus be
You can’t perform that action at this time.
0 commit comments