Commit 15cb013
committed
Auto merge of rust-lang#120717 - compiler-errors:cap-closure-kind, r=oli-obk
For async closures, cap closure kind, get rid of `by_mut_body`
Right now we have three `AsyncFn*` traits, and three corresponding futures that are returned by the `call_*` functions for them. This is fine, but it is a bit excessive, since the future returned by `AsyncFn` and `AsyncFnMut` are identical. Really, the only distinction we need to make with these bodies is "by ref" and "by move".
This PR removes `AsyncFn::CallFuture` and renames `AsyncFnMut::CallMutFuture` to `AsyncFnMut::CallRefFuture`. This simplifies MIR building for async closures, since we don't need to build an extra "by mut" body, but just a "by move" body which is materially different.
We need to do a bit of delicate handling of the ClosureKind for async closures, since we need to "cap" it to `AsyncFnMut` in some cases when we only care about what body we're looking for.
This also fixes a bug where `<{async closure} as Fn>::call` was returning a body that takes the async-closure receiver *by move*.
This also helps align the `AsyncFn` traits to the `LendingFn` traits' eventual designs.2 files changed
+14
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2042 | 2042 | | |
2043 | 2043 | | |
2044 | 2044 | | |
2045 | | - | |
| 2045 | + | |
2046 | 2046 | | |
2047 | | - | |
| 2047 | + | |
2048 | 2048 | | |
2049 | 2049 | | |
2050 | 2050 | | |
2051 | 2051 | | |
2052 | 2052 | | |
2053 | 2053 | | |
2054 | | - | |
2055 | | - | |
2056 | | - | |
| 2054 | + | |
2057 | 2055 | | |
2058 | 2056 | | |
2059 | 2057 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | 13 | | |
20 | 14 | | |
21 | | - | |
| 15 | + | |
22 | 16 | | |
23 | 17 | | |
24 | 18 | | |
| |||
30 | 24 | | |
31 | 25 | | |
32 | 26 | | |
33 | | - | |
| 27 | + | |
34 | 28 | | |
35 | | - | |
| 29 | + | |
36 | 30 | | |
37 | 31 | | |
38 | 32 | | |
39 | 33 | | |
40 | 34 | | |
41 | | - | |
| 35 | + | |
42 | 36 | | |
43 | 37 | | |
44 | 38 | | |
| |||
72 | 66 | | |
73 | 67 | | |
74 | 68 | | |
75 | | - | |
76 | | - | |
77 | | - | |
| 69 | + | |
78 | 70 | | |
79 | 71 | | |
80 | 72 | | |
| |||
84 | 76 | | |
85 | 77 | | |
86 | 78 | | |
87 | | - | |
| 79 | + | |
88 | 80 | | |
89 | | - | |
| 81 | + | |
90 | 82 | | |
91 | 83 | | |
92 | 84 | | |
| |||
97 | 89 | | |
98 | 90 | | |
99 | 91 | | |
100 | | - | |
| 92 | + | |
101 | 93 | | |
102 | 94 | | |
103 | 95 | | |
| |||
109 | 101 | | |
110 | 102 | | |
111 | 103 | | |
112 | | - | |
| 104 | + | |
113 | 105 | | |
114 | | - | |
| 106 | + | |
115 | 107 | | |
116 | 108 | | |
117 | 109 | | |
| |||
122 | 114 | | |
123 | 115 | | |
124 | 116 | | |
125 | | - | |
| 117 | + | |
126 | 118 | | |
127 | 119 | | |
128 | 120 | | |
| |||
0 commit comments