summaryrefslogtreecommitdiffstats
path: root/tests/ui/coroutine/coroutine-region-requirements.rs
blob: 8bc34fdd2f053e71dd7d5064a25ace79b8afb251 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#![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() {}