os-rust/tests/ui/coroutine/coroutine-region-requirements.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
480 B
Rust
Raw Normal View History

#![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 {
let mut g = #[coroutine] || {
2018-10-12 15:16:29 +01:00
yield;
x
};
loop {
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() {}