about summary refs log tree commit diff
path: root/library/core/src/panic.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/core/src/panic.rs')
-rw-r--r--library/core/src/panic.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/library/core/src/panic.rs b/library/core/src/panic.rs
index f8f3962ce55..e702056f00a 100644
--- a/library/core/src/panic.rs
+++ b/library/core/src/panic.rs
@@ -206,15 +206,16 @@ pub macro const_panic {
         // add the `rustc_allow_const_fn_unstable`. This is okay to do
         // because both variants will panic, just with different messages.
         #[rustc_allow_const_fn_unstable(const_eval_select)]
-        #[inline(always)]
+        #[inline(always)] // inline the wrapper
         #[track_caller]
         #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_panic", since = "CURRENT_RUSTC_VERSION"))]
         const fn do_panic($($arg: $ty),*) -> ! {
             $crate::intrinsics::const_eval_select!(
-                @capture { $($arg: $ty),* } -> !:
-                if const #[track_caller] {
+                @capture { $($arg: $ty = $arg),* } -> !:
+                #[noinline]
+                if const #[track_caller] #[inline] { // Inline this, to prevent codegen
                     $crate::panic!($const_msg)
-                } else #[track_caller] {
+                } else #[track_caller] { // Do not inline this, it makes perf worse
                     $crate::panic!($runtime_msg)
                 }
             )