2018-08-30 14:18:55 +02:00
|
|
|
// run-pass
|
2021-12-03 15:32:51 +00:00
|
|
|
// needs-unwind
|
2018-09-25 23:51:35 +02:00
|
|
|
#![allow(unused_variables)]
|
2018-08-31 15:58:57 +02:00
|
|
|
#![allow(stable_features)]
|
2018-08-30 14:18:55 +02:00
|
|
|
|
2018-07-23 03:14:42 +01:00
|
|
|
#![feature(std_panic)]
|
2015-12-17 23:51:55 -08:00
|
|
|
|
2016-02-11 12:34:41 +01:00
|
|
|
// ignore-emscripten no threads support
|
|
|
|
|
2015-12-17 23:51:55 -08:00
|
|
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
|
|
|
use std::panic;
|
|
|
|
use std::thread;
|
|
|
|
|
|
|
|
static A: AtomicUsize = AtomicUsize::new(0);
|
|
|
|
|
|
|
|
fn main() {
|
2016-03-15 20:38:58 -07:00
|
|
|
panic::set_hook(Box::new(|_| ()));
|
|
|
|
panic::set_hook(Box::new(|info| { A.fetch_add(1, Ordering::SeqCst); }));
|
2015-12-17 23:51:55 -08:00
|
|
|
|
|
|
|
let _ = thread::spawn(|| {
|
|
|
|
panic!();
|
|
|
|
}).join();
|
|
|
|
|
|
|
|
assert_eq!(1, A.load(Ordering::SeqCst));
|
|
|
|
}
|