]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0727.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0727.md
1 A `yield` clause was used in an `async` context.
2
3 Erroneous code example:
4
5 ```compile_fail,E0727,edition2018
6 #![feature(generators)]
7
8 fn main() {
9     let generator = || {
10         async {
11             yield;
12         }
13     };
14 }
15 ```
16
17 Here, the `yield` keyword is used in an `async` block,
18 which is not yet supported.
19
20 To fix this error, you have to move `yield` out of the `async` block:
21
22 ```edition2018
23 #![feature(generators)]
24
25 fn main() {
26     let generator = || {
27         yield;
28     };
29 }
30 ```