]> git.proxmox.com Git - rustc.git/blob - tests/ui/issues/issue-68696-catch-during-unwind.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / 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 }