about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2016-03-15 20:19:03 -0700
committerSteven Fackler <sfackler@gmail.com>2016-03-15 20:51:48 -0700
commit157e1bc6811b033bf640b68ffdf3ea0f1b804ccf (patch)
tree13a8cee43328e75a5c34084f88e8be68963e994d /src/libstd
parent159eae8b8b32f76c1ae945cdfc52fb77ffc01d52 (diff)
downloadrust-157e1bc6811b033bf640b68ffdf3ea0f1b804ccf.tar.gz
rust-157e1bc6811b033bf640b68ffdf3ea0f1b804ccf.zip
Make set_hook take a Box<Fn>
Otherwise there's no good way of re-registering a hook you got out of
take_hook.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/panic.rs2
-rw-r--r--src/libstd/panicking.rs3
2 files changed, 2 insertions, 3 deletions
diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs
index 56d638d9df3..aff11d036f8 100644
--- a/src/libstd/panic.rs
+++ b/src/libstd/panic.rs
@@ -29,7 +29,7 @@ pub use panicking::{take_hook, set_hook, PanicInfo, Location};
 #[rustc_deprecated(since = "1.9.0", reason = "renamed to set_hook")]
 #[unstable(feature = "panic_handler", reason = "awaiting feedback", issue = "30449")]
 pub fn set_handler<F>(handler: F) where F: Fn(&PanicInfo) + 'static + Sync + Send {
-    set_hook(handler)
+    set_hook(Box::new(handler))
 }
 
 ///
diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs
index 556dddf9387..fd6a15b0f69 100644
--- a/src/libstd/panicking.rs
+++ b/src/libstd/panicking.rs
@@ -58,12 +58,11 @@ static FIRST_PANIC: AtomicBool = AtomicBool::new(true);
 ///
 /// Panics if called from a panicking thread.
 #[unstable(feature = "panic_handler", reason = "awaiting feedback", issue = "30449")]
-pub fn set_hook<F>(hook: F) where F: Fn(&PanicInfo) + 'static + Sync + Send {
+pub fn set_hook(hook: Box<Fn(&PanicInfo) + 'static + Sync + Send>) {
     if thread::panicking() {
         panic!("cannot modify the panic hook from a panicking thread");
     }
 
-    let hook = Box::new(hook);
     unsafe {
         let lock = HOOK_LOCK.write();
         let old_hook = HOOK;