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 · Fixed by #62383
Closed

Unhelpful span in async type inference error #62382

Aaron1011 opened this issue Jul 4, 2019 · 0 comments · Fixed by #62383
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints A-inference Area: Type inference C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Aaron1011
Copy link
Member

Aaron1011 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
Fixes rust-lang#62382

Previously, we would point at the spawn of the 'await' expression,
instead of the actual expression with an unknown type.
@jonas-schievink jonas-schievink added A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-inference Area: Type inference labels Jul 4, 2019
Centril added a commit to Centril/rust that referenced this issue Jul 5, 2019
…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
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints A-inference Area: Type inference C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants