0
0
mirror of https://github.com/rust-lang/rust.git synced 2024-11-25 12:12:19 +01:00
rust/tests/ui/coroutine/overlap-locals.rs
Oli Scherer aef0f4024a Error on using yield without also using #[coroutine] on the closure
And suggest adding the `#[coroutine]` to the closure
2024-04-24 08:05:29 +00:00

31 lines
562 B
Rust

//@ run-pass
#![feature(coroutines, stmt_expr_attributes)]
fn main() {
let a = #[coroutine]
|| {
{
let w: i32 = 4;
yield;
println!("{:?}", w);
}
{
let x: i32 = 5;
yield;
println!("{:?}", x);
}
{
let y: i32 = 6;
yield;
println!("{:?}", y);
}
{
let z: i32 = 7;
yield;
println!("{:?}", z);
}
};
assert_eq!(8, std::mem::size_of_val(&a));
}