about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-03-18 09:21:43 -0700
committerbors <bors@rust-lang.org>2016-03-18 09:21:43 -0700
commit24bb607e7d65ebfc487eba62e053ac049f140efc (patch)
tree5488e6cdaba0a034870a1b0b459b9685e7352ed6 /src/test
parent235d77457d80b549dad3ac36d94f235208a1eafb (diff)
parent50fda1eead10af900a7b7c9f07983937e66bcc3c (diff)
downloadrust-24bb607e7d65ebfc487eba62e053ac049f140efc.tar.gz
rust-24bb607e7d65ebfc487eba62e053ac049f140efc.zip
Auto merge of #32282 - sfackler:panic-hook, r=alexcrichton
Adjustments to the panic hook API

Rename `set_handler` and `take_handler` to `set_hook` and `take_hook` since we're not actually "handling" (i.e. fixing) anything.

Also alter `set_hook` to take a `Box<Fn(&PanicInfo) + 'static + Sync + Send>` rather than a parameterized closure since there's otherwise no easy way to re-register a hook that came from `take_hook`.

cc #30449

r? @aturon
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/panic-handler-chain.rs10
-rw-r--r--src/test/run-pass/panic-handler-flail-wildly.rs30
-rw-r--r--src/test/run-pass/panic-handler-set-twice.rs4
3 files changed, 22 insertions, 22 deletions
diff --git a/src/test/run-pass/panic-handler-chain.rs b/src/test/run-pass/panic-handler-chain.rs
index 1ed592d3d6b..7c2e3f0c91b 100644
--- a/src/test/run-pass/panic-handler-chain.rs
+++ b/src/test/run-pass/panic-handler-chain.rs
@@ -17,12 +17,12 @@ static A: AtomicUsize = AtomicUsize::new(0);
 static B: AtomicUsize = AtomicUsize::new(0);
 
 fn main() {
-    panic::set_handler(|_| { A.fetch_add(1, Ordering::SeqCst); });
-    let handler = panic::take_handler();
-    panic::set_handler(move |info| {
+    panic::set_hook(Box::new(|_| { A.fetch_add(1, Ordering::SeqCst); }));
+    let hook = panic::take_hook();
+    panic::set_hook(Box::new(move |info| {
         B.fetch_add(1, Ordering::SeqCst);
-        handler(info);
-    });
+        hook(info);
+    }));
 
     let _ = thread::spawn(|| {
         panic!();
diff --git a/src/test/run-pass/panic-handler-flail-wildly.rs b/src/test/run-pass/panic-handler-flail-wildly.rs
index 39ea987f71b..311310712df 100644
--- a/src/test/run-pass/panic-handler-flail-wildly.rs
+++ b/src/test/run-pass/panic-handler-flail-wildly.rs
@@ -15,28 +15,28 @@ use std::panic;
 use std::thread;
 
 fn a() {
-    panic::set_handler(|_| println!("hello yes this is a"));
-    panic::take_handler();
-    panic::set_handler(|_| println!("hello yes this is a part 2"));
-    panic::take_handler();
+    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();
 }
 
 fn b() {
-    panic::take_handler();
-    panic::take_handler();
-    panic::take_handler();
-    panic::take_handler();
-    panic::take_handler();
+    panic::take_hook();
+    panic::take_hook();
+    panic::take_hook();
+    panic::take_hook();
+    panic::take_hook();
     panic!();
 }
 
 fn c() {
-    panic::set_handler(|_| ());
-    panic::set_handler(|_| ());
-    panic::set_handler(|_| ());
-    panic::set_handler(|_| ());
-    panic::set_handler(|_| ());
-    panic::set_handler(|_| ());
+    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(|_| ()));
     panic!();
 }
 
diff --git a/src/test/run-pass/panic-handler-set-twice.rs b/src/test/run-pass/panic-handler-set-twice.rs
index ed9a02c1d3e..196e08a63a7 100644
--- a/src/test/run-pass/panic-handler-set-twice.rs
+++ b/src/test/run-pass/panic-handler-set-twice.rs
@@ -18,8 +18,8 @@ use std::thread;
 static A: AtomicUsize = AtomicUsize::new(0);
 
 fn main() {
-    panic::set_handler(|_| ());
-    panic::set_handler(|info| { A.fetch_add(1, Ordering::SeqCst); });
+    panic::set_hook(Box::new(|_| ()));
+    panic::set_hook(Box::new(|info| { A.fetch_add(1, Ordering::SeqCst); }));
 
     let _ = thread::spawn(|| {
         panic!();