Rollup merge of #69974 - GuillaumeGomez:cleanup-e0434, r=Dylan-DPC
Clean up E0434 explanation r? @Dylan-DPC
This commit is contained in:
commit
1d8f5f0ff5
@ -1,6 +1,4 @@
|
|||||||
This error indicates that a variable usage inside an inner function is invalid
|
A variable used inside an inner function comes from a dynamic environment.
|
||||||
because the variable comes from a dynamic environment. Inner functions do not
|
|
||||||
have access to their containing environment.
|
|
||||||
|
|
||||||
Erroneous code example:
|
Erroneous code example:
|
||||||
|
|
||||||
@ -14,8 +12,8 @@ fn foo() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Functions do not capture local variables. To fix this error, you can replace the
|
Inner functions do not have access to their containing environment. To fix this
|
||||||
function with a closure:
|
error, you can replace the function with a closure:
|
||||||
|
|
||||||
```
|
```
|
||||||
fn foo() {
|
fn foo() {
|
||||||
@ -26,7 +24,7 @@ fn foo() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
or replace the captured variable with a constant or a static item:
|
Or replace the captured variable with a constant or a static item:
|
||||||
|
|
||||||
```
|
```
|
||||||
fn foo() {
|
fn foo() {
|
||||||
|
Loading…
Reference in New Issue
Block a user