about summary refs log tree commit diff
path: root/tests/ui/coroutine/gen_block_move.fixed
blob: e58c9b3f9fe324872d0b20e99070eadd7e18eb78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//@ edition: 2024
//@ run-rustfix
#![feature(gen_blocks)]

fn moved() -> impl Iterator<Item = u32> {
    let mut x = "foo".to_string();
    gen move { //~ ERROR: gen block may outlive the current function
        yield 42;
        if x == "foo" { return }
        x.clear();
        for x in 3..6 { yield x }
    }
}

fn main() {
    for _ in moved() {}
}