Skip to content

Commit 6e66bfd

Browse files
authored
Rollup merge of #69480 - GuillaumeGomez:clean-up-e0373, r=Dylan-DPC
Clean up E0373 explanation r? @Dylan-DPC
2 parents d4700a8 + 129ac01 commit 6e66bfd

File tree

1 file changed

+7
-3
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+7
-3
lines changed

Diff for: src/librustc_error_codes/error_codes/E0373.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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
66
fn 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+
1216
Notice that `x` is stack-allocated by `foo()`. By default, Rust captures
1317
closed-over data by reference. This means that once `foo()` returns, `x` no
1418
longer exists. An attempt to access `x` within the closure would thus be

0 commit comments

Comments
 (0)