2018-09-06 07:41:12 -05:00
|
|
|
// run-pass
|
2021-12-03 09:32:51 -06:00
|
|
|
// needs-unwind
|
2018-09-06 07:41:12 -05:00
|
|
|
|
2017-10-22 22:01:00 -05:00
|
|
|
|
2017-07-07 18:12:44 -05:00
|
|
|
#![feature(generators, generator_trait)]
|
|
|
|
|
|
|
|
use std::ops::Generator;
|
2018-10-04 13:49:38 -05:00
|
|
|
use std::pin::Pin;
|
2017-07-07 18:12:44 -05:00
|
|
|
use std::panic;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut foo = || {
|
|
|
|
if true {
|
|
|
|
panic!();
|
|
|
|
}
|
|
|
|
yield;
|
|
|
|
};
|
|
|
|
|
|
|
|
let res = panic::catch_unwind(panic::AssertUnwindSafe(|| {
|
2020-01-25 13:03:10 -06:00
|
|
|
Pin::new(&mut foo).resume(())
|
2017-07-07 18:12:44 -05:00
|
|
|
}));
|
|
|
|
assert!(res.is_err());
|
|
|
|
|
|
|
|
for _ in 0..10 {
|
|
|
|
let res = panic::catch_unwind(panic::AssertUnwindSafe(|| {
|
2020-01-25 13:03:10 -06:00
|
|
|
Pin::new(&mut foo).resume(())
|
2017-07-07 18:12:44 -05:00
|
|
|
}));
|
|
|
|
assert!(res.is_err());
|
|
|
|
}
|
|
|
|
}
|