about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-08-16 10:15:46 +0000
committerbors <bors@rust-lang.org>2025-08-16 10:15:46 +0000
commit2e2642e641a941f0a1400c7827fd89aa86fef8f4 (patch)
treea5101e62d507eefd818274b0fcb477437c50b3c2 /library/core/src
parent1ae7c4907275f10b3db9e886bc8809ec063e45ee (diff)
parent08acba30718281a068ab978f8feded9b871ec9db (diff)
downloadrust-2e2642e641a941f0a1400c7827fd89aa86fef8f4.tar.gz
rust-2e2642e641a941f0a1400c7827fd89aa86fef8f4.zip
Auto merge of #145304 - m-ou-se:simplify-panic, r=oli-obk
Revert "Partially outline code inside the panic! macro".

This reverts https://github.com/rust-lang/rust/pull/115670

Without any tests/benchmarks that show some improvement, it's hard to know whether the change had any positive effect. (And if it did, whether that effect is still achieved today.)
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/panic.rs45
-rw-r--r--library/core/src/panicking.rs11
2 files changed, 1 insertions, 55 deletions
diff --git a/library/core/src/panic.rs b/library/core/src/panic.rs
index 5fa340a6147..7a42b3d0fc7 100644
--- a/library/core/src/panic.rs
+++ b/library/core/src/panic.rs
@@ -48,7 +48,6 @@ pub macro panic_2015 {
 #[allow_internal_unstable(panic_internals, const_format_args)]
 #[rustc_diagnostic_item = "core_panic_2021_macro"]
 #[rustc_macro_transparency = "semitransparent"]
-#[cfg(feature = "panic_immediate_abort")]
 pub macro panic_2021 {
     () => (
         $crate::panicking::panic("explicit panic")
@@ -65,50 +64,6 @@ pub macro panic_2021 {
 }
 
 #[doc(hidden)]
-#[unstable(feature = "edition_panic", issue = "none", reason = "use panic!() instead")]
-#[allow_internal_unstable(
-    panic_internals,
-    core_intrinsics,
-    const_dispatch,
-    const_eval_select,
-    const_format_args,
-    rustc_attrs
-)]
-#[rustc_diagnostic_item = "core_panic_2021_macro"]
-#[rustc_macro_transparency = "semitransparent"]
-#[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();
-    }),
-    // 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<T: $crate::fmt::Display>(arg: &T) -> ! {
-            $crate::panicking::panic_display(arg)
-        }
-        panic_cold_display(&$arg);
-    }),
-    ($($t:tt)+) => ({
-        // Semicolon to prevent temporaries inside the formatting machinery from
-        // being considered alive in the caller after the panic_fmt call.
-        $crate::panicking::panic_fmt($crate::const_format_args!($($t)+));
-    }),
-}
-
-#[doc(hidden)]
 #[unstable(feature = "edition_panic", issue = "none", reason = "use unreachable!() instead")]
 #[allow_internal_unstable(panic_internals)]
 #[rustc_diagnostic_item = "unreachable_2015_macro"]
diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs
index 812bc5e6145..804a12ee477 100644
--- a/library/core/src/panicking.rs
+++ b/library/core/src/panicking.rs
@@ -233,14 +233,6 @@ pub fn panic_nounwind_nobacktrace(expr: &'static str) -> ! {
     panic_nounwind_fmt(fmt::Arguments::new_const(&[expr]), /* force_no_backtrace */ true);
 }
 
-#[track_caller]
-#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)]
-#[cfg_attr(feature = "panic_immediate_abort", inline)]
-#[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable
-pub const fn panic_explicit() -> ! {
-    panic_display(&"explicit panic");
-}
-
 #[inline]
 #[track_caller]
 #[rustc_diagnostic_item = "unreachable_display"] // needed for `non-fmt-panics` lint
@@ -260,9 +252,8 @@ pub const fn panic_str_2015(expr: &str) -> ! {
 
 #[inline]
 #[track_caller]
+#[lang = "panic_display"] // needed for const-evaluated panics
 #[rustc_do_not_const_check] // hooked by const-eval
-// enforce a &&str argument in const-check and hook this by const-eval
-#[rustc_const_panic_str]
 #[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable
 pub const fn panic_display<T: fmt::Display>(x: &T) -> ! {
     panic_fmt(format_args!("{}", *x));