rust/tests/ui/coroutine/unsized-capture-across-yield.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
537 B
Rust

#![feature(coroutine_trait)]
#![feature(coroutines)]
#![feature(unsized_locals)]
//~^ WARN the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes
use std::ops::Coroutine;
fn capture() -> impl Coroutine {
let b: [u8] = *(Box::new([]) as Box<[u8]>);
#[coroutine]
move || {
println!("{:?}", &b);
//~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
yield;
for elem in b.iter() {}
}
}
fn main() {
capture();
}