async fn recur(n : u32) -> u32 {
match n {
0 | 1 => 1,
_ => n + Box::new(recur(n-1)).await // using `Box::pin` compiles
}
}
this results in
error: cannot check whether the hidden type of opaque type satisfies auto traits
--> src/lib.rs:4:38
|
4 | _ => n + Box::new(recur(n-1)).await // using `Box::pin` compiles
| ^^^^^
|
note: opaque type is declared here
--> src/lib.rs:1:1
|
1 | async fn recur(n : u32) -> u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
--> src/lib.rs:1:10
|
1 | async fn recur(n : u32) -> u32 {
| ^^^^^
= note: required for `Box<impl Future<Output = u32>>` to implement `Future`
= note: required for `Box<impl Future<Output = u32>>` to implement `IntoFuture`
error[E0391]: cycle detected when computing type of opaque `recur::{opaque#0}`
--> src/lib.rs:1:1
|
1 | async fn recur(n : u32) -> u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires type-checking `recur`...
--> src/lib.rs:1:1
|
1 | async fn recur(n : u32) -> u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which again requires computing type of opaque `recur::{opaque#0}`, completing the cycle
note: cycle used when computing type of `recur::{opaque#0}`
--> src/lib.rs:1:1
|
1 | async fn recur(n : u32) -> u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
We should instead mention that the async function does not implement Unpin, causing Box<opaque> to not implement IntoFuture.
cc @oli-obk this error should get significantly improved by #122192
this results in
We should instead mention that the async function does not implement
Unpin, causingBox<opaque>to not implementIntoFuture.cc @oli-obk this error should get significantly improved by #122192