@@ -38,10 +38,9 @@ use crate::panic::{Location, PanicInfo};
3838/// site as much as possible (so that `panic!()` has as low an impact
3939/// on (e.g.) the inlining of other functions as possible), by moving
4040/// the actual formatting into this shared place.
41- #[ cold]
4241// If panic_immediate_abort, inline the abort call,
4342// otherwise avoid inlining because of it is cold path.
44- #[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) ) ]
43+ #[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) , cold ) ]
4544#[ cfg_attr( feature = "panic_immediate_abort" , inline) ]
4645#[ track_caller]
4746#[ lang = "panic_fmt" ] // needed for const-evaluated panics
@@ -67,8 +66,7 @@ pub const fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! {
6766
6867/// Like panic_fmt, but without unwinding and track_caller to reduce the impact on codesize.
6968/// Also just works on `str`, as a `fmt::Arguments` needs more space to be passed.
70- #[ cold]
71- #[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) ) ]
69+ #[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) , cold) ]
7270#[ cfg_attr( feature = "panic_immediate_abort" , inline) ]
7371#[ rustc_nounwind]
7472pub fn panic_str_nounwind ( msg : & ' static str ) -> ! {
@@ -96,10 +94,9 @@ pub fn panic_str_nounwind(msg: &'static str) -> ! {
9694// above.
9795
9896/// The underlying implementation of libcore's `panic!` macro when no formatting is used.
99- #[ cold]
10097// never inline unless panic_immediate_abort to avoid code
10198// bloat at the call sites as much as possible
102- #[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) ) ]
99+ #[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) , cold ) ]
103100#[ cfg_attr( feature = "panic_immediate_abort" , inline) ]
104101#[ track_caller]
105102#[ rustc_const_unstable( feature = "core_panic" , issue = "none" ) ]
@@ -138,8 +135,8 @@ pub const fn panic_display<T: fmt::Display>(x: &T) -> ! {
138135 panic_fmt ( format_args ! ( "{}" , * x) ) ;
139136}
140137
141- #[ cold]
142- #[ cfg_attr( not ( feature = "panic_immediate_abort" ) , inline( never ) ) ]
138+ #[ cfg_attr ( not ( feature = "panic_immediate_abort" ) , inline ( never ) , cold) ]
139+ #[ cfg_attr( feature = "panic_immediate_abort" , inline) ]
143140#[ track_caller]
144141#[ lang = "panic_bounds_check" ] // needed by codegen for panic on OOB array/slice access
145142fn panic_bounds_check ( index : usize , len : usize ) -> ! {
@@ -154,8 +151,8 @@ fn panic_bounds_check(index: usize, len: usize) -> ! {
154151///
155152/// This function is called directly by the codegen backend, and must not have
156153/// any extra arguments (including those synthesized by track_caller).
157- #[ cold]
158- #[ inline ( never ) ]
154+ #[ cfg_attr ( not ( feature = "panic_immediate_abort" ) , inline ( never ) , cold) ]
155+ #[ cfg_attr ( feature = "panic_immediate_abort" , inline ) ]
159156#[ lang = "panic_no_unwind" ] // needed by codegen for panic in nounwind function
160157#[ rustc_nounwind]
161158fn panic_no_unwind ( ) -> ! {
@@ -185,7 +182,8 @@ pub enum AssertKind {
185182}
186183
187184/// Internal function for `assert_eq!` and `assert_ne!` macros
188- #[ cold]
185+ #[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) , cold) ]
186+ #[ cfg_attr( feature = "panic_immediate_abort" , inline) ]
189187#[ track_caller]
190188#[ doc( hidden) ]
191189pub fn assert_failed < T , U > (
@@ -202,7 +200,8 @@ where
202200}
203201
204202/// Internal function for `assert_match!`
205- #[ cold]
203+ #[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) , cold) ]
204+ #[ cfg_attr( feature = "panic_immediate_abort" , inline) ]
206205#[ track_caller]
207206#[ doc( hidden) ]
208207pub fn assert_matches_failed < T : fmt:: Debug + ?Sized > (
@@ -221,6 +220,8 @@ pub fn assert_matches_failed<T: fmt::Debug + ?Sized>(
221220}
222221
223222/// Non-generic version of the above functions, to avoid code bloat.
223+ #[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) , cold) ]
224+ #[ cfg_attr( feature = "panic_immediate_abort" , inline) ]
224225#[ track_caller]
225226fn assert_failed_inner (
226227 kind : AssertKind ,
0 commit comments