From b9c5105a6015bfd92789ae21e9fda4ebd164e4cd Mon Sep 17 00:00:00 2001 From: Federico Maria Morrone Date: Fri, 5 Aug 2022 01:38:50 +0200 Subject: [PATCH] Add no_panic_impl feature --- library/std/Cargo.toml | 3 +++ library/std/src/panicking.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 229e546e08549..d9d6a1fa1a14b 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -68,6 +68,9 @@ system-llvm-libunwind = ["unwind/system-llvm-libunwind"] # Make panics and failed asserts immediately abort without formatting any message panic_immediate_abort = ["core/panic_immediate_abort"] +# Disables the `panic_impl` lang item +no_panic_impl = [] + # Enable std_detect default features for stdarch/crates/std_detect: # https://github.com/rust-lang/stdarch/blob/master/crates/std_detect/Cargo.toml std_detect_file_io = ["std_detect/std_detect_file_io"] diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index 25c9201f2ed3a..f4ea78575f9f1 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -528,7 +528,7 @@ pub fn panicking() -> bool { /// Entry point of panics from the libcore crate (`panic_impl` lang item). #[cfg(not(test))] -#[panic_handler] +#[cfg_attr(not(feature = "no_panic_impl"), panic_handler)] pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! { struct PanicPayload<'a> { inner: &'a fmt::Arguments<'a>,