]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-68696-catch-during-unwind.rs
Merge commit '370c397ec9169809e5ad270079712e0043514240' into sync_cg_clif-2022-03-20
[rust.git] / src / test / ui / issues / issue-68696-catch-during-unwind.rs
1 // Checks that catch_unwind can be used if unwinding is already in progress.
2 // Used to fail when standard library had been compiled with debug assertions,
3 // due to incorrect assumption that a current thread is not panicking when
4 // entering the catch_unwind.
5 //
6 // run-pass
7
8 use std::panic::catch_unwind;
9
10 #[derive(Default)]
11 struct Guard;
12
13 impl Drop for Guard {
14     fn drop(&mut self) {
15         let _ = catch_unwind(|| {});
16     }
17 }
18
19 fn main() {
20     #[cfg(panic = "unwind")]
21     let _ = catch_unwind(|| {
22         let _guard = Guard::default();
23         panic!();
24     });
25 }