Open
Description
I tried this code:
use core::future::IntoFuture;
use futures::future::{ready, Ready};
struct Foo;
impl IntoFuture for &Foo {
type Output = u32;
type IntoFuture = Ready<u32>;
fn into_future(self) -> Self::IntoFuture {
ready(2)
}
}
#[tokio::main]
async fn main() {
assert_eq!(Foo.await, 2);
}
I expected to see this happen: Compiles and runs successfully. The .await
performs auto-ref, and <&Foo as IntoFuture>::into_future()
is called.
Instead, this happened:
error[E0277]: `Foo` is not a future
--> src/main.rs:16:19
|
16 | assert_eq!(Foo.await, 2);
| ^^^^^^
| |
| `Foo` is not a future
| help: remove the `.await`
|
= help: the trait `futures::Future` is not implemented for `Foo`
= note: Foo must be a future or must implement `IntoFuture` to be awaited
= help: the trait `std::future::IntoFuture` is implemented for `&Foo`
= note: required for `Foo` to implement `std::future::IntoFuture`
Meta
rustc --version --verbose
:
1.71.0-nightly (2023-05-12 4a59ba4d54a3ec0d8ea1)
@rustbot label A-async-await
Metadata
Metadata
Assignees
Labels
Area: Async & AwaitArea: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Async-await issues that have been triaged during a working group meeting.Category: This is a bug.Relevant to the language team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.Working group: Async & await