File tree Expand file tree Collapse file tree 1 file changed +45
-1
lines changed Expand file tree Collapse file tree 1 file changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -948,6 +948,51 @@ use something_which_doesnt_exist;
948948Please verify you didn't misspell the import's name.
949949"## ,
950950
951+ E0434 : r##"
952+ This error indicates that a variable usage inside an inner function is invalid
953+ because the variable comes from a dynamic environment. Inner functions do not
954+ have access to their containing environment.
955+
956+ Example of erroneous code:
957+
958+ ```compile_fail
959+ fn foo() {
960+ let y = 5;
961+ fn bar() -> u32 {
962+ y // error: can't capture dynamic environment in a fn item; use the
963+ // || { ... } closure form instead.
964+ }
965+ }
966+ ```
967+
968+ Functions do not capture local variables. To fix this error, you can replace the
969+ function with a closure:
970+
971+ ```
972+ fn foo() {
973+ let y = 5;
974+ let bar = || {
975+ y
976+ };
977+ }
978+ ```
979+
980+ or replace the captured variable with a constant or a static item:
981+
982+ ```
983+ fn foo() {
984+ static mut X: u32 = 4;
985+ const Y: u32 = 5;
986+ fn bar() -> u32 {
987+ unsafe {
988+ X = 3;
989+ }
990+ Y
991+ }
992+ }
993+ ```
994+ "## ,
995+
951996E0435 : r##"
952997A non-constant value was used to initialise a constant. Example of erroneous
953998code:
@@ -1044,5 +1089,4 @@ register_diagnostics! {
10441089 E0421 , // unresolved associated const
10451090 E0427 , // cannot use `ref` binding mode with ...
10461091 E0429 , // `self` imports are only allowed within a { } list
1047- E0434 , // can't capture dynamic environment in a fn item
10481092}
You can’t perform that action at this time.
0 commit comments