2022-05-21 15:26:58 -04:00
|
|
|
// ignore-compare-mode-nll
|
|
|
|
// revisions: base nll
|
|
|
|
// [nll]compile-flags: -Zborrowck=mir
|
|
|
|
|
2018-10-12 15:16:29 +01:00
|
|
|
#![feature(generators, generator_trait)]
|
|
|
|
use std::ops::{Generator, GeneratorState};
|
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 = || {
|
|
|
|
yield;
|
|
|
|
x
|
2022-05-21 15:26:58 -04:00
|
|
|
//[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
|
2018-10-12 15:16:29 +01:00
|
|
|
};
|
|
|
|
loop {
|
2020-01-25 20:03:10 +01:00
|
|
|
match Pin::new(&mut g).resume(()) {
|
2018-10-12 15:16:29 +01:00
|
|
|
GeneratorState::Complete(c) => return c,
|
2022-05-21 15:26:58 -04:00
|
|
|
//[nll]~^ ERROR lifetime may not live long enough
|
2018-10-12 15:16:29 +01:00
|
|
|
GeneratorState::Yielded(_) => (),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|