rust/tests/ui/coroutine/gen_block_move.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
386 B
Rust
Raw Permalink Normal View History

2023-10-24 04:50:49 -05:00
//@ 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() {}
}