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