Rollup merge of #61941 - cramertj:no-more-yield-errors, r=centril

Preserve generator and yield source for error messages

Previously, error messages after HIR lowering all referred
to generators and yield, regardless of whether the original
source was a generator or an async/await body. This change
tracks the kind of each generator and yield source in order
to provide appropriately tailored error messages.

Fixes #60615.
This commit is contained in:
Mazdak Farrokhzad 2019-06-19 01:52:13 +02:00 committed by GitHub
commit fde341a4ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 221 additions and 128 deletions

View file

@ -7,9 +7,9 @@ async fn bar<T>() -> () {}
async fn foo() {
bar().await;
//~^ ERROR type inside generator must be known in this context
//~^ ERROR type inside `async` object must be known in this context
//~| NOTE cannot infer type for `T`
//~| NOTE the type is part of the generator because of this `yield`
//~| NOTE the type is part of the `async` object because of this `await`
//~| NOTE in this expansion of desugaring of `await`
}
fn main() {}

View file

@ -1,10 +1,10 @@
error[E0698]: type inside generator must be known in this context
error[E0698]: type inside `async` object must be known in this context
--> $DIR/unresolved_type_param.rs:9:5
|
LL | bar().await;
| ^^^ cannot infer type for `T`
|
note: the type is part of the generator because of this `yield`
note: the type is part of the `async` object because of this `await`
--> $DIR/unresolved_type_param.rs:9:5
|
LL | bar().await;