2018-09-06 12:41:12 +00:00
|
|
|
//@ run-pass
|
2021-12-03 15:32:51 +00:00
|
|
|
//@ needs-unwind
|
2018-09-06 12:41:12 +00:00
|
|
|
|
2017-10-23 03:01:00 +00:00
|
|
|
|
2024-04-11 13:15:34 +00:00
|
|
|
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
|
2017-07-07 23:12:44 +00:00
|
|
|
|
2023-10-19 16:06:43 +00:00
|
|
|
use std::ops::Coroutine;
|
2018-10-04 18:49:38 +00:00
|
|
|
use std::pin::Pin;
|
2017-07-07 23:12:44 +00:00
|
|
|
use std::panic;
|
|
|
|
|
|
|
|
fn main() {
|
2024-04-11 13:15:34 +00:00
|
|
|
let mut foo = #[coroutine] || {
|
2017-07-07 23:12:44 +00:00
|
|
|
if true {
|
|
|
|
panic!();
|
|
|
|
}
|
|
|
|
yield;
|
|
|
|
};
|
|
|
|
|
|
|
|
let res = panic::catch_unwind(panic::AssertUnwindSafe(|| {
|
2020-01-25 19:03:10 +00:00
|
|
|
Pin::new(&mut foo).resume(())
|
2017-07-07 23:12:44 +00:00
|
|
|
}));
|
|
|
|
assert!(res.is_err());
|
|
|
|
|
|
|
|
for _ in 0..10 {
|
|
|
|
let res = panic::catch_unwind(panic::AssertUnwindSafe(|| {
|
2020-01-25 19:03:10 +00:00
|
|
|
Pin::new(&mut foo).resume(())
|
2017-07-07 23:12:44 +00:00
|
|
|
}));
|
|
|
|
assert!(res.is_err());
|
|
|
|
}
|
|
|
|
}
|