blob: 71a68ff684af31c6656fb61cc9bd20ecafa0e7fa [file] [log] [blame]
// run-pass
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(generators, generator_trait)]
use std::ops::{GeneratorState, Generator};
use std::pin::Pin;
use std::panic;
fn main() {
let mut foo = || {
if true {
return
}
yield;
};
match Pin::new(&mut foo).resume() {
GeneratorState::Complete(()) => {}
s => panic!("bad state: {:?}", s),
}
match panic::catch_unwind(move || Pin::new(&mut foo).resume()) {
Ok(_) => panic!("generator successfully resumed"),
Err(_) => {}
}
}