summaryrefslogtreecommitdiffstats
path: root/tests/ui/generator/generator-region-requirements.rs
blob: 7269a79ca3f9806f6003a14a52937f4faf6104c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#![feature(generators, generator_trait)]
use std::ops::{Generator, GeneratorState};
use std::pin::Pin;

fn dangle(x: &mut i32) -> &'static mut i32 {
    let mut g = || {
        yield;
        x
    };
    loop {
        match Pin::new(&mut g).resume(()) {
            GeneratorState::Complete(c) => return c,
            //~^ ERROR lifetime may not live long enough
            GeneratorState::Yielded(_) => (),
        }
    }
}

fn main() {}