Skip to content

Commit 035b1bf

Browse files
committed
Auto merge of rust-lang#140637 - m-ou-se:panic-simplify, r=<try>
Simplify expansion of panic!(). In rust-lang#115670, panic!() was changed to generate extra functions. However, it's unclear if it actually improved things. Let's try what happens if we remove it.
2 parents 62c5f58 + 8af0470 commit 035b1bf

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

library/core/src/panic.rs

+2-18
Original file line numberDiff line numberDiff line change
@@ -79,27 +79,11 @@ pub macro panic_2021 {
7979
#[cfg(not(feature = "panic_immediate_abort"))]
8080
pub macro panic_2021 {
8181
() => ({
82-
// Create a function so that the argument for `track_caller`
83-
// can be moved inside if possible.
84-
#[cold]
85-
#[track_caller]
86-
#[inline(never)]
87-
const fn panic_cold_explicit() -> ! {
88-
$crate::panicking::panic_explicit()
89-
}
90-
panic_cold_explicit();
82+
$crate::panicking::panic_explicit();
9183
}),
9284
// Special-case the single-argument case for const_panic.
9385
("{}", $arg:expr $(,)?) => ({
94-
#[cold]
95-
#[track_caller]
96-
#[inline(never)]
97-
#[rustc_const_panic_str] // enforce a &&str argument in const-check and hook this by const-eval
98-
#[rustc_do_not_const_check] // hooked by const-eval
99-
const fn panic_cold_display<T: $crate::fmt::Display>(arg: &T) -> ! {
100-
$crate::panicking::panic_display(arg)
101-
}
102-
panic_cold_display(&$arg);
86+
$crate::panicking::panic_display(&$arg);
10387
}),
10488
($($t:tt)+) => ({
10589
// Semicolon to prevent temporaries inside the formatting machinery from

0 commit comments

Comments
 (0)