]> git.proxmox.com Git - rustc.git/blame - src/librustc_error_codes/error_codes/E0698.md
New upstream version 1.47.0+dfsg1
[rustc.git] / src / librustc_error_codes / error_codes / E0698.md
CommitLineData
60c5eb7d
XL
1When using generators (or async) all type variables must be bound so a
2generator can be constructed.
3
4Erroneous code example:
5
f9f354fc 6```edition2018,compile_fail,E0698
60c5eb7d
XL
7async fn bar<T>() -> () {}
8
9async fn foo() {
10 bar().await; // error: cannot infer type for `T`
11}
12```
13
14In the above example `T` is unknowable by the compiler.
15To fix this you must bind `T` to a concrete type such as `String`
16so that a generator can then be constructed:
17
18```edition2018
19async fn bar<T>() -> () {}
20
21async fn foo() {
22 bar::<String>().await;
23 // ^^^^^^^^ specify type explicitly
24}
25```