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:
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_
const Experimental
MacrosΒ§
- panic_
const πExperimental
EnumsΒ§
- Assert
Kind π»Experimental
FunctionsΒ§
- assert_
failed π»Experimental - Internal function for
assert_eq!
andassert_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_ fmt Experimental - This function is used instead of panic_fmt in const eval.
- panic
Experimental - 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_
display Experimental - panic_
explicit Experimental - panic_
fmt Experimental - 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_
nounwind Experimental - 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, callpanic_nounwind_fmt
directly. - panic_
nounwind_ fmt Experimental - Like
panic_fmt
, but for non-unwinding panics. - panic_
nounwind_ nobacktrace Experimental - Like
panic_nounwind
, but also inhibits showing a backtrace. - panic_
null_ πpointer_ dereference Experimental - panic_
str_ 2015 Experimental - This exists solely for the 2015 edition
panic!
macro to trigger a lint onpanic!(my_str_variable);
. - unreachable_
display Experimental