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.
This commit is contained in:
Taylor Cramer 2019-06-18 14:34:51 -07:00
parent b01a257da1
commit d67db0042c
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;