From 8af047089a8781e6cb886323a8033b2c92817ebe Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sun, 4 May 2025 16:20:38 +0200 Subject: [PATCH] Simplify expansion of panic!(). --- library/core/src/panic.rs | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/library/core/src/panic.rs b/library/core/src/panic.rs index 5fa340a6147f6..2b157e17ad4b4 100644 --- a/library/core/src/panic.rs +++ b/library/core/src/panic.rs @@ -79,27 +79,11 @@ pub macro panic_2021 { #[cfg(not(feature = "panic_immediate_abort"))] pub macro panic_2021 { () => ({ - // Create a function so that the argument for `track_caller` - // can be moved inside if possible. - #[cold] - #[track_caller] - #[inline(never)] - const fn panic_cold_explicit() -> ! { - $crate::panicking::panic_explicit() - } - panic_cold_explicit(); + $crate::panicking::panic_explicit(); }), // Special-case the single-argument case for const_panic. ("{}", $arg:expr $(,)?) => ({ - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] // enforce a &&str argument in const-check and hook this by const-eval - #[rustc_do_not_const_check] // hooked by const-eval - const fn panic_cold_display(arg: &T) -> ! { - $crate::panicking::panic_display(arg) - } - panic_cold_display(&$arg); + $crate::panicking::panic_display(&$arg); }), ($($t:tt)+) => ({ // Semicolon to prevent temporaries inside the formatting machinery from