rust/tests/ui/generator/generator-region-requirements.rs
2023-10-20 21:14:01 +00:00

20 lines
445 B
Rust

#![feature(coroutines, coroutine_trait)]
use std::ops::{Coroutine, CoroutineState};
use std::pin::Pin;
fn dangle(x: &mut i32) -> &'static mut i32 {
let mut g = || {
yield;
x
};
loop {
match Pin::new(&mut g).resume(()) {
CoroutineState::Complete(c) => return c,
//~^ ERROR lifetime may not live long enough
CoroutineState::Yielded(_) => (),
}
}
}
fn main() {}