File tree 1 file changed +9
-5
lines changed
src/librustc_error_codes/error_codes
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 1
- Recursion in an ` async fn ` requires boxing. For example, this will not compile:
1
+ An [ ` async ` ] function used recursion without boxing.
2
+
3
+ Erroneous code example:
2
4
3
5
``` edition2018,compile_fail,E0733
4
6
async fn foo(n: usize) {
@@ -8,8 +10,8 @@ async fn foo(n: usize) {
8
10
}
9
11
```
10
12
11
- To achieve async recursion, the ` async fn ` needs to be desugared
12
- such that the ` Future ` is explicit in the return type:
13
+ To perform async recursion, the ` async fn ` needs to be desugared such that the
14
+ ` Future ` is explicit in the return type:
13
15
14
16
``` edition2018,compile_fail,E0720
15
17
use std::future::Future;
@@ -36,5 +38,7 @@ fn foo_recursive(n: usize) -> Pin<Box<dyn Future<Output = ()>>> {
36
38
}
37
39
```
38
40
39
- The ` Box<...> ` ensures that the result is of known size,
40
- and the pin is required to keep it in the same place in memory.
41
+ The ` Box<...> ` ensures that the result is of known size, and the pin is
42
+ required to keep it in the same place in memory.
43
+
44
+ [ `async` ] : https://doc.rust-lang.org/std/keyword.async.html
You can’t perform that action at this time.
0 commit comments