-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #59111 - gilescope:generator-better-errors, r=nikomatsakis
Improved error message when type must be bound due to generator. Fixes #58930. Keen to get some feedback - is this as minimal as we can get it or is there an existing visitor I could repurpose?
- Loading branch information
Showing
9 changed files
with
135 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Provoke an unresolved type error (T). | ||
// Error message should pinpoint the type parameter T as needing to be bound | ||
// (rather than give a general error message) | ||
// edition:2018 | ||
#![feature(futures_api, async_await, await_macro)] | ||
async fn bar<T>() -> () {} | ||
|
||
async fn foo() { | ||
await!(bar()); | ||
//~^ ERROR type inside generator must be known in this context | ||
//~| NOTE cannot infer type for `T` | ||
//~| NOTE the type is part of the generator because of this `yield` | ||
} | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error[E0698]: type inside generator must be known in this context | ||
--> $DIR/unresolved_type_param.rs:9:16 | ||
| | ||
LL | await!(bar()); | ||
| ^^^ cannot infer type for `T` | ||
| | ||
note: the type is part of the generator because of this `yield` | ||
--> $DIR/unresolved_type_param.rs:9:9 | ||
| | ||
LL | await!(bar()); | ||
| ^^^^^^^^^^^^^^ | ||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0698`. |