Skip to content

Commit 50fda1e

Browse files
committed
Update rpass tests for panic hooks
1 parent 157e1bc commit 50fda1e

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

src/test/run-pass/panic-handler-chain.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ static A: AtomicUsize = AtomicUsize::new(0);
1717
static B: AtomicUsize = AtomicUsize::new(0);
1818

1919
fn main() {
20-
panic::set_handler(|_| { A.fetch_add(1, Ordering::SeqCst); });
21-
let handler = panic::take_handler();
22-
panic::set_handler(move |info| {
20+
panic::set_hook(Box::new(|_| { A.fetch_add(1, Ordering::SeqCst); }));
21+
let hook = panic::take_hook();
22+
panic::set_hook(Box::new(move |info| {
2323
B.fetch_add(1, Ordering::SeqCst);
24-
handler(info);
25-
});
24+
hook(info);
25+
}));
2626

2727
let _ = thread::spawn(|| {
2828
panic!();

src/test/run-pass/panic-handler-flail-wildly.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,28 @@ use std::panic;
1515
use std::thread;
1616

1717
fn a() {
18-
panic::set_handler(|_| println!("hello yes this is a"));
19-
panic::take_handler();
20-
panic::set_handler(|_| println!("hello yes this is a part 2"));
21-
panic::take_handler();
18+
panic::set_hook(Box::new(|_| println!("hello yes this is a")));
19+
panic::take_hook();
20+
panic::set_hook(Box::new(|_| println!("hello yes this is a part 2")));
21+
panic::take_hook();
2222
}
2323

2424
fn b() {
25-
panic::take_handler();
26-
panic::take_handler();
27-
panic::take_handler();
28-
panic::take_handler();
29-
panic::take_handler();
25+
panic::take_hook();
26+
panic::take_hook();
27+
panic::take_hook();
28+
panic::take_hook();
29+
panic::take_hook();
3030
panic!();
3131
}
3232

3333
fn c() {
34-
panic::set_handler(|_| ());
35-
panic::set_handler(|_| ());
36-
panic::set_handler(|_| ());
37-
panic::set_handler(|_| ());
38-
panic::set_handler(|_| ());
39-
panic::set_handler(|_| ());
34+
panic::set_hook(Box::new(|_| ()));
35+
panic::set_hook(Box::new(|_| ()));
36+
panic::set_hook(Box::new(|_| ()));
37+
panic::set_hook(Box::new(|_| ()));
38+
panic::set_hook(Box::new(|_| ()));
39+
panic::set_hook(Box::new(|_| ()));
4040
panic!();
4141
}
4242

src/test/run-pass/panic-handler-set-twice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use std::thread;
1818
static A: AtomicUsize = AtomicUsize::new(0);
1919

2020
fn main() {
21-
panic::set_handler(|_| ());
22-
panic::set_handler(|info| { A.fetch_add(1, Ordering::SeqCst); });
21+
panic::set_hook(Box::new(|_| ()));
22+
panic::set_hook(Box::new(|info| { A.fetch_add(1, Ordering::SeqCst); }));
2323

2424
let _ = thread::spawn(|| {
2525
panic!();

0 commit comments

Comments
 (0)