Commit 3ef303b
authored
Rollup merge of rust-lang#119978 - compiler-errors:async-closure-captures, r=oli-obk
Move async closure parameters into the resultant closure's future eagerly
Move async closure parameters into the closure's resultant future eagerly.
Before, we used to desugar `async |p1, p2, ..| { body }` as `|p1, p2, ..| { || async { body } }`. Now, we desugar the above like `|p1, p2, ..| { async move { let p1 = p1; let p2 = p2; ... body } }`. This mirrors the same desugaring that `async fn` does with its parameter types, and the compiler literally uses the same code via a shared helper function.
This removes the necessity for E0708, since now expressions like `async |x: i32| { x }` will not give you confusing borrow errors.
This does *not* fix the case where async closures have self-borrows. This will come with a general implementation of async closures, which is still in the works.
r? oli-obkFile tree
13 files changed
+350
-320
lines changed- compiler
- rustc_ast_lowering
- src
- rustc_error_codes/src/error_codes
- rustc_hir_typeck/src
- src/tools/clippy
- clippy_lints/src
- tests/ui/author
- tests/ui/async-await
13 files changed
+350
-320
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 17 | | |
22 | 18 | | |
23 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | 148 | | |
157 | 149 | | |
158 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
1028 | 1027 | | |
1029 | 1028 | | |
1030 | 1029 | | |
1031 | | - | |
1032 | | - | |
1033 | | - | |
1034 | | - | |
1035 | 1030 | | |
1036 | 1031 | | |
1037 | 1032 | | |
1038 | 1033 | | |
1039 | 1034 | | |
1040 | 1035 | | |
1041 | | - | |
1042 | | - | |
1043 | | - | |
1044 | 1036 | | |
1045 | | - | |
1046 | | - | |
1047 | | - | |
1048 | | - | |
1049 | | - | |
1050 | 1037 | | |
1051 | 1038 | | |
1052 | | - | |
| 1039 | + | |
1053 | 1040 | | |
1054 | 1041 | | |
1055 | 1042 | | |
1056 | 1043 | | |
1057 | 1044 | | |
1058 | 1045 | | |
1059 | 1046 | | |
1060 | | - | |
1061 | | - | |
1062 | | - | |
1063 | | - | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
1064 | 1050 | | |
1065 | | - | |
| 1051 | + | |
1066 | 1052 | | |
1067 | | - | |
| 1053 | + | |
1068 | 1054 | | |
1069 | | - | |
| 1055 | + | |
| 1056 | + | |
1070 | 1057 | | |
1071 | | - | |
| 1058 | + | |
| 1059 | + | |
1072 | 1060 | | |
1073 | 1061 | | |
1074 | 1062 | | |
1075 | 1063 | | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
1076 | 1067 | | |
1077 | 1068 | | |
1078 | 1069 | | |
| |||
0 commit comments