Closed
Description
E.g. consider:
#![feature(async_await)]
fn foo() {
let x = async move {
Err(())?;
1
};
}
which yields the diagnostic:
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
--> src/lib.rs:5:9
|
5 | Err(())?;
| ^^^^^^^^ cannot use the `?` operator in a function that returns `{integer}`
|
= help: the trait `std::ops::Try` is not implemented for `{integer}`
= note: required by `std::ops::Try::from_error`
Ostensibly the user might think of fn foo
as "the function" but it is in fact the async
block that is "the function" here. That seems like something which would confuse users who are not familiar with the lowering and whatnot (most users).
Metadata
Metadata
Assignees
Labels
Area: Async & AwaitArea: Messages for errors, warnings, and lintsAsync-await issues that are part of the "polish" areaAsync-await issues that have been triaged during a working group meeting.Error messages that can be tackled with `#[rustc_on_unimplemented]`Relevant to the compiler team, which will review and decide on the PR/issue.