rust/tests/ui/generator/generator-region-requirements.rs

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

20 lines
445 B
Rust
Raw Normal View History

2018-10-12 14:16:29 +00:00
#![feature(generators, generator_trait)]
use std::ops::{Generator, GeneratorState};
2018-10-04 18:49:38 +00:00
use std::pin::Pin;
2018-10-12 14:16:29 +00:00
fn dangle(x: &mut i32) -> &'static mut i32 {
let mut g = || {
yield;
x
};
loop {
match Pin::new(&mut g).resume(()) {
2018-10-12 14:16:29 +00:00
GeneratorState::Complete(c) => return c,
2022-04-01 17:13:25 +00:00
//~^ ERROR lifetime may not live long enough
2018-10-12 14:16:29 +00:00
GeneratorState::Yielded(_) => (),
}
}
}
fn main() {}