]> git.lizzy.rs Git - rust.git/blob - tests/ui/panics/panic-handler-set-twice.rs
Rollup merge of #105526 - Xiretza:iter-from-generator-derive, r=scottmcm
[rust.git] / tests / ui / panics / panic-handler-set-twice.rs
1 // run-pass
2 // needs-unwind
3 #![allow(unused_variables)]
4 #![allow(stable_features)]
5
6 #![feature(std_panic)]
7
8 // ignore-emscripten no threads support
9
10 use std::sync::atomic::{AtomicUsize, Ordering};
11 use std::panic;
12 use std::thread;
13
14 static A: AtomicUsize = AtomicUsize::new(0);
15
16 fn main() {
17     panic::set_hook(Box::new(|_| ()));
18     panic::set_hook(Box::new(|info| { A.fetch_add(1, Ordering::SeqCst); }));
19
20     let _ = thread::spawn(|| {
21         panic!();
22     }).join();
23
24     assert_eq!(1, A.load(Ordering::SeqCst));
25 }