99
1010#![ deny( unsafe_op_in_unsafe_fn) ]
1111
12- use crate :: panic:: { BacktraceStyle , PanicInfo } ;
12+ use crate :: panic:: { BacktraceStyle , PanicHookInfo } ;
1313use core:: panic:: { Location , PanicPayload } ;
1414
1515use crate :: any:: Any ;
@@ -70,12 +70,12 @@ extern "C" fn __rust_foreign_exception() -> ! {
7070
7171enum Hook {
7272Default ,
73- Custom ( Box < dyn Fn ( & PanicInfo < ' _ > ) +' static +Sync +Send > ) ,
73+ Custom ( Box < dyn Fn ( & PanicHookInfo < ' _ > ) +' static +Sync +Send > ) ,
7474}
7575
7676impl Hook {
7777#[ inline]
78- fn into_box ( self ) ->Box < dyn Fn ( & PanicInfo < ' _ > ) +' static +Sync +Send > {
78+ fn into_box ( self ) ->Box < dyn Fn ( & PanicHookInfo < ' _ > ) +' static +Sync +Send > {
7979match self {
8080Hook :: Default =>Box :: new ( default_hook) ,
8181Hook :: Custom ( hook) => hook,
@@ -105,7 +105,7 @@ static HOOK: RwLock<Hook> = RwLock::new(Hook::Default);
105105///
106106/// [`take_hook`]: ./fn.take_hook.html
107107///
108- /// The hook is provided with a `PanicInfo ` struct which contains information
108+ /// The hook is provided with a `PanicHookInfo ` struct which contains information
109109/// about the origin of the panic, including the payload passed to `panic!` and
110110/// the source code location from which the panic originated.
111111///
@@ -129,7 +129,7 @@ static HOOK: RwLock<Hook> = RwLock::new(Hook::Default);
129129/// panic!("Normal panic");
130130/// ```
131131#[ stable( feature ="panic_hooks" , since ="1.10.0" ) ]
132- pub fn set_hook ( hook : Box < dyn Fn ( & PanicInfo < ' _ > ) +' static +Sync +Send > ) {
132+ pub fn set_hook ( hook : Box < dyn Fn ( & PanicHookInfo < ' _ > ) +' static +Sync +Send > ) {
133133if thread:: panicking ( ) {
134134panic ! ( "cannot modify the panic hook from a panicking thread" ) ;
135135}
@@ -173,7 +173,7 @@ pub fn set_hook(hook: Box<dyn Fn(&PanicInfo<'_>) + 'static + Sync + Send>) {
173173/// ```
174174#[ must_use]
175175#[ stable( feature ="panic_hooks" , since ="1.10.0" ) ]
176- pub fn take_hook ( ) ->Box < dyn Fn ( & PanicInfo < ' _ > ) +' static +Sync +Send > {
176+ pub fn take_hook ( ) ->Box < dyn Fn ( & PanicHookInfo < ' _ > ) +' static +Sync +Send > {
177177if thread:: panicking ( ) {
178178panic ! ( "cannot modify the panic hook from a panicking thread" ) ;
179179}
@@ -219,7 +219,7 @@ pub fn take_hook() -> Box<dyn Fn(&PanicInfo<'_>) + 'static + Sync + Send> {
219219#[ unstable( feature ="panic_update_hook" , issue ="92649" ) ]
220220pub fn update_hook < F > ( hook_fn : F )
221221where
222- F : Fn ( & ( dyn Fn ( & PanicInfo < ' _ > ) +Send +Sync +' static ) , & PanicInfo < ' _ > )
222+ F : Fn ( & ( dyn Fn ( & PanicHookInfo < ' _ > ) +Send +Sync +' static ) , & PanicHookInfo < ' _ > )
223223 +Sync
224224 +Send
225225 +' static ,
@@ -234,7 +234,7 @@ where
234234}
235235
236236/// The default panic handler.
237- fn default_hook ( info : & PanicInfo < ' _ > ) {
237+ fn default_hook ( info : & PanicHookInfo < ' _ > ) {
238238// If this is a double panic, make sure that we print a backtrace
239239// for this panic. Otherwise only print it if logging is enabled.
240240let backtrace =if info. force_no_backtrace ( ) {
@@ -791,10 +791,15 @@ fn rust_panic_with_hook(
791791// formatting.)
792792Hook :: Default if panic_output ( ) . is_none ( ) =>{ }
793793Hook :: Default =>{
794- default_hook ( & PanicInfo :: new ( location, payload. get ( ) , can_unwind, force_no_backtrace) ) ;
794+ default_hook ( & PanicHookInfo :: new (
795+ location,
796+ payload. get ( ) ,
797+ can_unwind,
798+ force_no_backtrace,
799+ ) ) ;
795800}
796801Hook :: Custom ( ref hook) =>{
797- hook ( & PanicInfo :: new ( location, payload. get ( ) , can_unwind, force_no_backtrace) ) ;
802+ hook ( & PanicHookInfo :: new ( location, payload. get ( ) , can_unwind, force_no_backtrace) ) ;
798803}
799804}
800805