about summary refs log tree commit diff
path: root/tests/ui/coroutine/coroutine-region-requirements.rs
blob: ab6f16995e2763f65a163489d459177f322ebd5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
use std::ops::{Coroutine, CoroutineState};
use std::pin::Pin;

fn dangle(x: &mut i32) -> &'static mut i32 {
    let mut g = #[coroutine] || {
        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() {}