summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_error_codes/src/error_codes/E0727.md
blob: 386daea0c57e3dfd4c6204c957b1572621221b32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
A `yield` clause was used in an `async` context.

Erroneous code example:

```compile_fail,E0727,edition2018
#![feature(generators)]

fn main() {
    let generator = || {
        async {
            yield;
        }
    };
}
```

Here, the `yield` keyword is used in an `async` block,
which is not yet supported.

To fix this error, you have to move `yield` out of the `async` block:

```edition2018
#![feature(generators)]

fn main() {
    let generator = || {
        yield;
    };
}
```