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

23 lines
432 B
Rust

#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
use std::marker::Unpin;
use std::ops::Coroutine;
pub fn foo() -> impl Coroutine<(), Yield = (), Return = ()> {
#[coroutine]
|| {
if false {
yield;
}
}
}
pub fn bar<T: 'static>(t: T) -> Box<Coroutine<(), Yield = T, Return = ()> + Unpin> {
Box::new(
#[coroutine]
|| {
yield t;
},
)
}