rust/tests/ui/coroutine/nested_coroutine.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

24 lines
473 B
Rust

//@ run-pass
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
use std::ops::{Coroutine, CoroutineState};
use std::pin::Pin;
fn main() {
let _coroutine = #[coroutine]
|| {
let mut sub_coroutine = #[coroutine]
|| {
yield 2;
};
match Pin::new(&mut sub_coroutine).resume(()) {
CoroutineState::Yielded(x) => {
yield x;
}
_ => panic!(),
};
};
}