File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
src/librustc_error_codes/error_codes Expand file tree Collapse file tree 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:
24
35``` edition2018,compile_fail,E0733
46async fn foo(n: usize) {
@@ -8,8 +10,8 @@ async fn foo(n: usize) {
810}
911```
1012
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:
1315
1416``` edition2018,compile_fail,E0720
1517use std::future::Future;
@@ -36,5 +38,7 @@ fn foo_recursive(n: usize) -> Pin<Box<dyn Future<Output = ()>>> {
3638}
3739```
3840
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