-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Status
Done