rust/tests/ui/async-await/non-trivial-drop.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

36 lines
487 B
Rust

//@ build-pass
//@ edition:2018
#![feature(coroutines)]
fn main() {
foo();
}
fn foo() {
#[coroutine] || {
yield drop(Config {
nickname: NonCopy,
b: NonCopy2,
}.nickname);
};
}
#[derive(Default)]
struct NonCopy;
impl Drop for NonCopy {
fn drop(&mut self) {}
}
#[derive(Default)]
struct NonCopy2;
impl Drop for NonCopy2 {
fn drop(&mut self) {}
}
#[derive(Default)]
struct Config {
nickname: NonCopy,
b: NonCopy2,
}