Improved error message when type must be bound due to generator.
Error now mentions type var name and span is highlighted.
This commit is contained in:
parent
3bee49f42b
commit
66e41bc675
9 changed files with 135 additions and 35 deletions
14
src/test/ui/generator/unresolved_type_param.rs
Normal file
14
src/test/ui/generator/unresolved_type_param.rs
Normal file
|
|
@ -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() {}
|
||||
16
src/test/ui/generator/unresolved_type_param.stderr
Normal file
16
src/test/ui/generator/unresolved_type_param.stderr
Normal file
|
|
@ -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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue