Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async blocks are leaky about wording wrt. `?` in diagnostics #62570

Centril opened this issue Jul 10, 2019 · 1 comment


None yet
2 participants
Copy link

commented Jul 10, 2019

E.g. consider:


fn foo() {
    let x = async move {


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/
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).


This comment has been minimized.

Copy link

commented Jul 11, 2019

I ran into this.

It's much more confusing if the outer function actually returns a result.

In a more complicated function the error message can be a real head scratcher.


async fn f() -> Result<bool, ()> {
    async {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.