diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 56d638d9df3b4..aff11d036f8f9 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(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 556dddf9387e2..fd6a15b0f69a3 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(hook: F) where F: Fn(&PanicInfo) + 'static + Sync + Send { +pub fn set_hook(hook: Box) { 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;