Module panicking

Source
πŸ”¬This is a nightly-only experimental API. (panic_internals)
Expand description

Panic support for core

In core, panicking is always done with a message, resulting in a core::panic::PanicInfo containing a fmt::Arguments. In std, however, panicking can be done with panic_any, which throws a Box<dyn Any> containing any type of value. Because of this, std::panic::PanicHookInfo is a different type, which contains a &dyn Any instead of a fmt::Arguments. std’s panic handler will convert the fmt::Arguments to a &dyn Any containing either a &'static str or String containing the formatted message.

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

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

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.

ModulesΒ§

panic_constExperimental

MacrosΒ§

panic_const πŸ”’ Experimental

EnumsΒ§

AssertKind πŸ‘» Experimental

FunctionsΒ§

assert_failed πŸ‘» Experimental
Internal function for assert_eq! and assert_ne! macros
assert_failed_inner πŸ”’ Experimental
Non-generic version of the above functions, to avoid code bloat.
assert_matches_failed πŸ‘» Experimental
Internal function for assert_match!
const_panic_fmtExperimental
This function is used instead of panic_fmt in const eval.
panicExperimental
The underlying implementation of core’s panic! macro when no formatting is used.
panic_bounds_check πŸ”’ Experimental
panic_cannot_unwind πŸ”’ Experimental
Panics because we cannot unwind out of a function.
panic_displayExperimental
panic_explicitExperimental
panic_fmtExperimental
The entry point for panicking with a formatted message.
panic_in_cleanup πŸ”’ Experimental
Panics because we are unwinding out of a destructor during cleanup.
panic_misaligned_pointer_dereference πŸ”’ Experimental
panic_nounwindExperimental
Like panic, but without unwinding and track_caller to reduce the impact on codesize on the caller. If you want #[track_caller] for nicer errors, call panic_nounwind_fmt directly.
panic_nounwind_fmtExperimental
Like panic_fmt, but for non-unwinding panics.
panic_nounwind_nobacktraceExperimental
Like panic_nounwind, but also inhibits showing a backtrace.
panic_null_pointer_dereference πŸ”’ Experimental
panic_str_2015Experimental
This exists solely for the 2015 edition panic! macro to trigger a lint on panic!(my_str_variable);.
unreachable_displayExperimental