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

Improve error span for async type inference error #62383

Merged
merged 1 commit into from
Jul 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/generator_interior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
// If unresolved type isn't a ty_var then unresolved_type_span is None
self.fcx.need_type_info_err_in_generator(
self.kind,
unresolved_type_span.unwrap_or(yield_data.span),
unresolved_type_span.unwrap_or(source_span),
unresolved_type,
)
.span_note(yield_data.span, &*note)
Expand Down
17 changes: 17 additions & 0 deletions src/test/ui/async-await/async-error-span.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// edition:2018
#![feature(async_await)]

// Regression test for issue #62382

use std::future::Future;

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

async fn foo() {
let a; //~ ERROR type inside `async` object must be known in this context
get_future().await;
}

fn main() {}
15 changes: 15 additions & 0 deletions src/test/ui/async-await/async-error-span.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0698]: type inside `async` object must be known in this context
--> $DIR/async-error-span.rs:13:9
|
LL | let a;
| ^ cannot infer type
|
note: the type is part of the `async` object because of this `await`
--> $DIR/async-error-span.rs:14:5
|
LL | get_future().await;
| ^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0698`.