]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generator/panic-safe.rs
Auto merge of #98051 - davidtwco:split-dwarf-stabilization, r=wesleywiser
[rust.git] / src / test / ui / generator / panic-safe.rs
1 // run-pass
2 // needs-unwind
3
4 // ignore-wasm32-bare compiled with panic=abort by default
5
6 #![feature(generators, generator_trait)]
7
8 use std::ops::Generator;
9 use std::pin::Pin;
10 use std::panic;
11
12 fn main() {
13     let mut foo = || {
14         if true {
15             panic!();
16         }
17         yield;
18     };
19
20     let res = panic::catch_unwind(panic::AssertUnwindSafe(|| {
21         Pin::new(&mut foo).resume(())
22     }));
23     assert!(res.is_err());
24
25     for _ in 0..10 {
26         let res = panic::catch_unwind(panic::AssertUnwindSafe(|| {
27             Pin::new(&mut foo).resume(())
28         }));
29         assert!(res.is_err());
30     }
31 }