rust/tests/ui/panics/panic-handler-flail-wildly.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.1 KiB
Rust
Raw Normal View History

//@ run-pass
//@ needs-unwind
2019-06-29 15:51:44 +00:00
#![allow(stable_features)]
2019-06-29 15:51:44 +00:00
#![allow(unused_must_use)]
//@ needs-threads
2018-07-23 02:14:42 +00:00
#![feature(std_panic)]
2015-12-18 07:51:55 +00:00
use std::panic;
use std::thread;
fn a() {
2016-03-16 03:38:58 +00:00
panic::set_hook(Box::new(|_| println!("hello yes this is a")));
panic::take_hook();
panic::set_hook(Box::new(|_| println!("hello yes this is a part 2")));
panic::take_hook();
2015-12-18 07:51:55 +00:00
}
fn b() {
2016-03-16 03:38:58 +00:00
panic::take_hook();
panic::take_hook();
panic::take_hook();
panic::take_hook();
panic::take_hook();
2015-12-18 07:51:55 +00:00
panic!();
}
fn c() {
2016-03-16 03:38:58 +00:00
panic::set_hook(Box::new(|_| ()));
panic::set_hook(Box::new(|_| ()));
panic::set_hook(Box::new(|_| ()));
panic::set_hook(Box::new(|_| ()));
panic::set_hook(Box::new(|_| ()));
panic::set_hook(Box::new(|_| ()));
2015-12-18 07:51:55 +00:00
panic!();
}
fn main() {
for _ in 0..10 {
let mut handles = vec![];
for _ in 0..10 {
handles.push(thread::spawn(a));
}
for _ in 0..10 {
handles.push(thread::spawn(b));
}
for _ in 0..10 {
handles.push(thread::spawn(c));
}
for handle in handles {
let _ = handle.join();
}
}
}