about summary refs log tree commit diff
path: root/compiler/rustc_error_codes
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-11-08 06:56:06 +0000
committerMichael Goulet <michael@errs.io>2024-01-08 20:30:21 +0000
commit82a22154815b70e5701064bef59d3334f5bc1cf7 (patch)
tree40d6223ac17b8293ea29e1b2266817f56c56d75c /compiler/rustc_error_codes
parentdfb9f5df2c9f3c60f2541b3804cb6be1b5c66e63 (diff)
downloadrust-82a22154815b70e5701064bef59d3334f5bc1cf7.tar.gz
rust-82a22154815b70e5701064bef59d3334f5bc1cf7.zip
Don't check for recursion in generator witness fields
Diffstat (limited to 'compiler/rustc_error_codes')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0733.md16
1 files changed, 15 insertions, 1 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0733.md b/compiler/rustc_error_codes/src/error_codes/E0733.md
index 051b75148e5..cceb0880350 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0733.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0733.md
@@ -13,7 +13,7 @@ async fn foo(n: usize) {
 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
+```edition2018,compile_fail,E0733
 use std::future::Future;
 fn foo_desugared(n: usize) -> impl Future<Output = ()> {
     async move {
@@ -41,4 +41,18 @@ 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.
 
+Alternatively, the recursive call-site can be boxed:
+
+```edition2018
+use std::future::Future;
+use std::pin::Pin;
+fn foo_recursive(n: usize) -> impl Future<Output = ()> {
+    async move {
+        if n > 0 {
+            Box::pin(foo_recursive(n - 1)).await;
+        }
+    }
+}
+```
+
 [`async`]: https://doc.rust-lang.org/std/keyword.async.html