0
0
mirror of https://github.com/rust-lang/rust.git synced 2024-11-25 12:12:19 +01:00
rust/tests/ui/coroutine/resume-arg-late-bound.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

18 lines
467 B
Rust

//! Tests that we cannot produce a coroutine that accepts a resume argument
//! with any lifetime and then stores it across a `yield`.
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
use std::ops::Coroutine;
fn test(a: impl for<'a> Coroutine<&'a mut bool>) {}
fn main() {
let gen = #[coroutine] |arg: &mut bool| {
yield ();
*arg = true;
};
test(gen);
//~^ ERROR implementation of `Coroutine` is not general enough
}