🔬 This is a nightly-only experimental API. (core_panic)
Expand description

Panic support for libcore

The core library cannot define panicking, but it does declare panicking. This means that the functions inside of libcore are allowed to panic, but to be useful an upstream crate must define panicking for libcore to use. The current interface for panicking is:

fn panic_impl(pi: &core::panic::PanicInfo<'_>) -> !
Run

This definition allows for panicking with any general message, but it does not allow for failing with a Box<Any> value. (PanicInfo just contains a &(dyn Any + Send), for which we fill in a dummy value in PanicInfo::internal_constructor.) The reason for this is that libcore is not allowed to allocate.

This module contains a few other panicking functions, but these are just the necessary lang items for the compiler. All panics are funneled through this one function. The actual symbol is declared through the #[panic_handler] attribute.

Enums

AssertKindExperimental

Functions

assert_failedExperimental

Internal function for assert_eq! and assert_ne! macros

assert_failed_inner 🔒 Experimental

Non-generic version of the above functions, to avoid code bloat.

Internal function for assert_match!

const_panic_fmtExperimental

This function is used instead of panic_fmt in const eval.

panicExperimental

The underlying implementation of libcore’s panic! macro when no formatting is used.

panic_bounds_check 🔒 Experimental
panic_displayExperimental
panic_fmtExperimental

The entry point for panicking with a formatted message.

panic_no_unwind 🔒 Experimental
panic_strExperimental