mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-11-03 22:49:17 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			20 lines
		
	
	
		
			480 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			480 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
#![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() {}
 |