Open
Description
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=232bc66719a632fbcb8f5d400a58f74e
use core::future::Future;
use core::pin::Pin;
fn f() -> Pin<Box<dyn Unpin + Future<Output = ()>>> {
Box::pin(async {})
}
The current output is:
error[E0277]: `from_generator::GenFuture<[static generator@src/lib.rs:4:20: 4:22]>` cannot be unpinned
--> src/lib.rs:4:5
|
4 | Box::pin(async {})
| ^^^^^^^^^^^^^^^^^^ within `impl Future<Output = [async output]>`, the trait `Unpin` is not implemented for `from_generator::GenFuture<[static generator@src/lib.rs:4:20: 4:22]>`
|
= note: consider using `Box::pin`
= note: required because it appears within the type `impl Future<Output = [async output]>`
= note: required for the cast to the object type `dyn Future<Output = ()> + Unpin`
For more information about this error, try `rustc --explain E0277`.
Ideally the output should look like:
error[E0277]: async blocks cannot be unpinned
--> src/lib.rs:4:5
|
4 | Box::pin(async {})
| ^^^^^^^^^^^^^^^^^^ within `impl Future<Output = ()>`, the trait `Unpin` is not implemented for `from_generator::GenFuture<[static generator@src/lib.rs:4:20: 4:22]>`
|
= note: async blocks never implement `Unpin`
= note: required because it appears within the type `impl Future<Output = [async output]>`
= note: required for the cast to the object type `dyn Future<Output = ()> + Unpin`
warning: `Pin<Box<dyn Pin + Future<Output = ()>>>` is redundant and most likely not what you intended
= help: remove the `Unpin` requirement: `Pin<Box<dyn Future<Output = ()>>>`
For more information about this error, try `rustc --explain E0277`.
Pin<Box<T>>
is always Unpin
and therefore there's no need to require T: Unpin
.
Also note the "[async output]" message in the first block; that looks like an outright bug.