2024-04-11 13:15:34 +00:00
|
|
|
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
|
2023-10-19 16:06:43 +00:00
|
|
|
use std::ops::{Coroutine, CoroutineState};
|
2018-10-04 20:49:38 +02:00
|
|
|
use std::pin::Pin;
|
2018-10-12 15:16:29 +01:00
|
|
|
|
|
|
|
fn dangle(x: &mut i32) -> &'static mut i32 {
|
2024-04-11 13:15:34 +00:00
|
|
|
let mut g = #[coroutine] || {
|
2018-10-12 15:16:29 +01:00
|
|
|
yield;
|
|
|
|
x
|
|
|
|
};
|
|
|
|
loop {
|
2020-01-25 20:03:10 +01:00
|
|
|
match Pin::new(&mut g).resume(()) {
|
2023-10-19 16:06:43 +00:00
|
|
|
CoroutineState::Complete(c) => return c,
|
2022-04-01 13:13:25 -04:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2023-10-19 16:06:43 +00:00
|
|
|
CoroutineState::Yielded(_) => (),
|
2018-10-12 15:16:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|