]> git.proxmox.com Git - rustc.git/blame - src/test/ui/panics/panic-recover-propagate.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / panics / panic-recover-propagate.rs
CommitLineData
b7449926 1// run-pass
a2a8927a 2// needs-unwind
7453a54e
SL
3// ignore-emscripten no threads support
4
9fa01778 5use std::sync::atomic::{AtomicUsize, Ordering};
9cc50fc6
SL
6use std::panic;
7use std::thread;
8
9fa01778 9static A: AtomicUsize = AtomicUsize::new(0);
9cc50fc6
SL
10
11fn main() {
3157f602 12 panic::set_hook(Box::new(|_| {
9cc50fc6 13 A.fetch_add(1, Ordering::SeqCst);
3157f602 14 }));
9cc50fc6
SL
15
16 let result = thread::spawn(|| {
3157f602 17 let result = panic::catch_unwind(|| {
9cc50fc6
SL
18 panic!("hi there");
19 });
20
3157f602 21 panic::resume_unwind(result.unwrap_err());
9cc50fc6
SL
22 }).join();
23
a7813a04 24 let msg = *result.unwrap_err().downcast::<&'static str>().unwrap();
9cc50fc6
SL
25 assert_eq!("hi there", msg);
26 assert_eq!(1, A.load(Ordering::SeqCst));
27}