fn rust_panic_with_hook(
    payload: &mut dyn BoxMeUp,
    message: Option<&fmt::Arguments<'_>>,
    location: &Location<'_>,
) -> ! {
    let panics = update_panic_count(1);

    // If this is the third nested call (e.g., panics == 2, this is 0-indexed),
    // the panic hook probably triggered the last panic, otherwise the
    // double-panic check would have aborted the process. In this case abort the
    // process real quickly as we don't want to try calling it again as it'll
    // probably just panic again.
    if panics > 2 {
        util::dumb_print(format_args!(
            "thread panicked while processing \
                                       panic. aborting.\n"
        ));
        unsafe { intrinsics::abort() }
    }

    unsafe {
        let mut info = PanicInfo::internal_constructor(message, location);
        HOOK_LOCK.read();
        match HOOK {
            // Some platforms (like wasm) know that printing to stderr won't ever actually
            // print anything, and if that's the case we can skip the default
            // hook. Since string formatting happens lazily when calling `payload`
            // methods, this means we avoid formatting the string at all!
            // (The panic runtime might still call `payload.take_box()` though and trigger
            // formatting.)
            Hook::Default if panic_output().is_none() => {}
            Hook::Default => {
                info.set_payload(payload.get());
                default_hook(&info);
            }
            Hook::Custom(ptr) => {
                info.set_payload(payload.get());
                (*ptr)(&info);
            }
        };
        HOOK_LOCK.read_unlock();
    }

    if panics > 1 {
        // If a thread panics while it's already unwinding then we
        // have limited options. Currently our preference is to
        // just abort. In the future we may consider resuming
        // unwinding or otherwise exiting the thread cleanly.
        util::dumb_print(format_args!(
            "thread panicked while panicking. \
                                       aborting.\n"
        ));
        unsafe { intrinsics::abort() }
    }

    rust_panic(payload)
}
/// Central point for dispatching panics.
///
/// Executes the primary logic for a panic, including checking for recursive
/// panics, panic hooks, and finally dispatching to the panic runtime to either
/// abort or unwind.
Central point for dispatching panics.
Executes the primary logic for a panic, including checking for recursive
panics, panic hooks, and finally dispatching to the panic runtime to either
abort or unwind.
Central point for dispatching panics . Executes the primary logic for a panic including checking for recursive panics panic hooks and finally dispatching to the panic runtime to either abort or unwind .
fn rust_panic_with_hook(
    payload: &mut dyn BoxMeUp,
    message: Option<&fmt::Arguments<'_>>,
    location: &Location<'_>,
) -> ! {
    let panics = update_panic_count(1);
    // If this is the third nested call (e.g., panics == 2, this is 0-indexed),
    // the panic hook probably triggered the last panic, otherwise the
    // double-panic check would have aborted the process. In this case abort the
    // process real quickly as we don't want to try calling it again as it'll
    // probably just panic again.
    if panics > 2 {
        util::dumb_print(format_args!(
            "thread panicked while processing \
                                       panic. aborting.\n"
        ));
        unsafe { intrinsics::abort() }
    }
    unsafe {
        let mut info = PanicInfo::internal_constructor(message, location);
        HOOK_LOCK.read();
        match HOOK {
            // Some platforms (like wasm) know that printing to stderr won't ever actually
            // print anything, and if that's the case we can skip the default
            // hook. Since string formatting happens lazily when calling `payload`
            // methods, this means we avoid formatting the string at all!
            // (The panic runtime might still call `payload.take_box()` though and trigger
            // formatting.)
            Hook::Default if panic_output().is_none() => {}
            Hook::Default => {
                info.set_payload(payload.get());
                default_hook(&info);
            }
            Hook::Custom(ptr) => {
                info.set_payload(payload.get());
                (*ptr)(&info);
            }
        };
        HOOK_LOCK.read_unlock();
    }
    if panics > 1 {
        // If a thread panics while it's already unwinding then we
        // have limited options. Currently our preference is to
        // just abort. In the future we may consider resuming
        // unwinding or otherwise exiting the thread cleanly.
        util::dumb_print(format_args!(
            "thread panicked while panicking. \
                                       aborting.\n"
        ));
        unsafe { intrinsics::abort() }
    }
    rust_panic(payload)
}
fn rust_panic_with_hook ( payload : & mut dyn BoxMeUp , message : Option < & fmt :: Arguments < ' _ > > , location : & Location < ' _ > , ) -> ! { let panics = update_panic_count ( 1 ) ; // If this is the third nested call (e.g., panics == 2, this is 0-indexed), // the panic hook probably triggered the last panic, otherwise the // double-panic check would have aborted the process. In this case abort the // process real quickly as we don't want to try calling it again as it'll // probably just panic again. if panics > 2 { util :: dumb_print ( format_args ! ( " \
 \n " ) ) ; unsafe { intrinsics :: abort ( ) } } unsafe { let mut info = PanicInfo :: internal_constructor ( message , location ) ; HOOK_LOCK . read ( ) ; match HOOK { // Some platforms (like wasm) know that printing to stderr won't ever actually // print anything, and if that's the case we can skip the default // hook. Since string formatting happens lazily when calling `payload` // methods, this means we avoid formatting the string at all! // (The panic runtime might still call `payload.take_box()` though and trigger // formatting.) Hook :: Default if panic_output ( ) . is_none ( ) => { } Hook :: Default => { info . set_payload ( payload . get ( ) ) ; default_hook ( & info ) ; } Hook :: Custom ( ptr ) => { info . set_payload ( payload . get ( ) ) ; ( * ptr ) ( & info ) ; } } ; HOOK_LOCK . read_unlock ( ) ; } if panics > 1 { // If a thread panics while it's already unwinding then we // have limited options. Currently our preference is to // just abort. In the future we may consider resuming // unwinding or otherwise exiting the thread cleanly. util :: dumb_print ( format_args ! ( " \
 \n " ) ) ; unsafe { intrinsics :: abort ( ) } } rust_panic ( payload ) }
Central point for dispatching panics.
Central point for dispatching panics .
payload
&mut dyn BoxMeUp
message
Option<&fmt::Arguments<'_>>
location
&Location<'_>
payload
&mut dyn BoxMeUp
message
Option<&fmt::Arguments<'_>>
location
&Location<'_>