Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up E0733 explanation #74781

Merged
merged 1 commit into from
Aug 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/librustc_error_codes/error_codes/E0733.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Recursion in an `async fn` requires boxing. For example, this will not compile:
An [`async`] function used recursion without boxing.

Erroneous code example:

```edition2018,compile_fail,E0733
async fn foo(n: usize) {
Expand All @@ -8,8 +10,8 @@ async fn foo(n: usize) {
}
```

To achieve async recursion, the `async fn` needs to be desugared
such that the `Future` is explicit in the return type:
To perform async recursion, the `async fn` needs to be desugared such that the
`Future` is explicit in the return type:

```edition2018,compile_fail,E0720
use std::future::Future;
Expand All @@ -36,5 +38,7 @@ fn foo_recursive(n: usize) -> Pin<Box<dyn Future<Output = ()>>> {
}
```

The `Box<...>` ensures that the result is of known size,
and the pin is required to keep it in the same place in memory.
The `Box<...>` ensures that the result is of known size, and the pin is
required to keep it in the same place in memory.

[`async`]: https://doc.rust-lang.org/std/keyword.async.html