Closed
Description
When I compile the following code:
async fn fallible() -> Result<(), ()> { Ok(()) }
async fn caller() -> Result<(), ()> {
fallible() /* mising .await */ ?;
Ok(())
}
fn main() -> Result<(), ()> {
futures::executor::block_on(caller())
}
rustc says:
error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
--> src/main.rs:4:5
|
4 | fallible() /* mising .await */ ?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `?` operator cannot be applied to type `impl core::future::future::Future`
|
= help: the trait `std::ops::Try` is not implemented for `impl core::future::future::Future`
= note: required by `std::ops::Try::into_result`
I think it should notice that the program is trying to apply ?
to a future, and suggest awaiting it.
(If there is an existing issue for this, it is not labeled A-async-await
and A-suggestion-diagnostics
.)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done