summaryrefslogtreecommitdiffstats
path: root/tests/ui/coroutine/gen_block_move.rs
blob: abbf8132476c425de174190f7e3a335efeaa441f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// compile-flags: --edition 2024 -Zunstable-options
// run-rustfix
#![feature(gen_blocks)]

fn moved() -> impl Iterator<Item = u32> {
    let mut x = "foo".to_string();
    gen { //~ 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() {}
}