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

Unhelpful span in async type inference error #62382

Closed
Aaron1011 opened this issue Jul 4, 2019 · 0 comments

Comments

Projects
None yet
2 participants
@Aaron1011
Copy link
Contributor

commented Jul 4, 2019

The following snippet (playground):

#![feature(async_await)]

use std::future::Future;

fn get_future() -> impl Future<Output = ()> {
    panic!()
}

async fn foo() {
    let a;
    get_future().await;
}

fn main() {}

Gives the following error message:

error[E0698]: type inside `async` object must be known in this context
  --> infer_error.rs:11:5
   |
11 |     get_future().await;
   |     ^^^^^^^^^^^^^^^^^^ cannot infer type
   |
note: the type is part of the `async` object because of this `await`
  --> infer_error.rs:11:5
   |
11 |     get_future().await;
   |     ^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

This error is due to the unknown type of a. However, nothing in the span indicates that this is the case, making it extremely unclear what the proper fix is.

Aaron1011 added a commit to Aaron1011/rust that referenced this issue Jul 4, 2019

Improve error span for async type inference error
Fixes rust-lang#62382

Previously, we would point at the spawn of the 'await' expression,
instead of the actual expression with an unknown type.

Centril added a commit to Centril/rust that referenced this issue Jul 5, 2019

Rollup merge of rust-lang#62383 - Aaron1011:fix/async-error-span, r=v…
…arkor

Improve error span for async type inference error

Fixes rust-lang#62382

Previously, we would point at the spawn of the 'await' expression,
instead of the actual expression with an unknown type.

Centril added a commit to Centril/rust that referenced this issue Jul 5, 2019

Rollup merge of rust-lang#62383 - Aaron1011:fix/async-error-span, r=v…
…arkor

Improve error span for async type inference error

Fixes rust-lang#62382

Previously, we would point at the spawn of the 'await' expression,
instead of the actual expression with an unknown type.

@bors bors closed this in #62383 Jul 5, 2019

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.