Skip to content

Commit 157e1bc

Browse files
committed
Make set_hook take a Box<Fn>
Otherwise there's no good way of re-registering a hook you got out of take_hook.
1 parent 159eae8 commit 157e1bc

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/libstd/panic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub use panicking::{take_hook, set_hook, PanicInfo, Location};
2929
#[rustc_deprecated(since = "1.9.0", reason = "renamed to set_hook")]
3030
#[unstable(feature = "panic_handler", reason = "awaiting feedback", issue = "30449")]
3131
pub fn set_handler<F>(handler: F) where F: Fn(&PanicInfo) + 'static + Sync + Send {
32-
set_hook(handler)
32+
set_hook(Box::new(handler))
3333
}
3434

3535
///

src/libstd/panicking.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,11 @@ static FIRST_PANIC: AtomicBool = AtomicBool::new(true);
5858
///
5959
/// Panics if called from a panicking thread.
6060
#[unstable(feature = "panic_handler", reason = "awaiting feedback", issue = "30449")]
61-
pub fn set_hook<F>(hook: F) where F: Fn(&PanicInfo) + 'static + Sync + Send {
61+
pub fn set_hook(hook: Box<Fn(&PanicInfo) + 'static + Sync + Send>) {
6262
if thread::panicking() {
6363
panic!("cannot modify the panic hook from a panicking thread");
6464
}
6565

66-
let hook = Box::new(hook);
6766
unsafe {
6867
let lock = HOOK_LOCK.write();
6968
let old_hook = HOOK;

0 commit comments

Comments
 (0)