about summary refs log tree commit diff
path: root/compiler/rustc_error_codes/src/error_codes/E0727.md
blob: 7754186508f111a4cab8ada1ebf630f08971eb77 (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(coroutines, stmt_expr_attributes)]

fn main() {
    let coroutine = #[coroutine] || {
        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(coroutines, stmt_expr_attributes)]

fn main() {
    let coroutine = #[coroutine] || {
        yield;
    };
}
```