@@ -38,10 +38,9 @@ use crate::panic::{Location, PanicInfo};
38
38
/// site as much as possible (so that `panic!()` has as low an impact
39
39
/// on (e.g.) the inlining of other functions as possible), by moving
40
40
/// the actual formatting into this shared place.
41
- #[ cold]
42
41
// If panic_immediate_abort, inline the abort call,
43
42
// 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 ) ]
45
44
#[ cfg_attr( feature = "panic_immediate_abort" , inline) ]
46
45
#[ track_caller]
47
46
#[ lang = "panic_fmt" ] // needed for const-evaluated panics
@@ -67,8 +66,7 @@ pub const fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! {
67
66
68
67
/// Like panic_fmt, but without unwinding and track_caller to reduce the impact on codesize.
69
68
/// 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) ]
72
70
#[ cfg_attr( feature = "panic_immediate_abort" , inline) ]
73
71
#[ rustc_nounwind]
74
72
pub fn panic_str_nounwind ( msg : & ' static str ) -> ! {
@@ -96,10 +94,9 @@ pub fn panic_str_nounwind(msg: &'static str) -> ! {
96
94
// above.
97
95
98
96
/// The underlying implementation of libcore's `panic!` macro when no formatting is used.
99
- #[ cold]
100
97
// never inline unless panic_immediate_abort to avoid code
101
98
// 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 ) ]
103
100
#[ cfg_attr( feature = "panic_immediate_abort" , inline) ]
104
101
#[ track_caller]
105
102
#[ rustc_const_unstable( feature = "core_panic" , issue = "none" ) ]
@@ -138,8 +135,8 @@ pub const fn panic_display<T: fmt::Display>(x: &T) -> ! {
138
135
panic_fmt ( format_args ! ( "{}" , * x) ) ;
139
136
}
140
137
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) ]
143
140
#[ track_caller]
144
141
#[ lang = "panic_bounds_check" ] // needed by codegen for panic on OOB array/slice access
145
142
fn panic_bounds_check ( index : usize , len : usize ) -> ! {
@@ -154,8 +151,8 @@ fn panic_bounds_check(index: usize, len: usize) -> ! {
154
151
///
155
152
/// This function is called directly by the codegen backend, and must not have
156
153
/// 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 ) ]
159
156
#[ lang = "panic_no_unwind" ] // needed by codegen for panic in nounwind function
160
157
#[ rustc_nounwind]
161
158
fn panic_no_unwind ( ) -> ! {
@@ -185,7 +182,8 @@ pub enum AssertKind {
185
182
}
186
183
187
184
/// 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) ]
189
187
#[ track_caller]
190
188
#[ doc( hidden) ]
191
189
pub fn assert_failed < T , U > (
@@ -202,7 +200,8 @@ where
202
200
}
203
201
204
202
/// 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) ]
206
205
#[ track_caller]
207
206
#[ doc( hidden) ]
208
207
pub fn assert_matches_failed < T : fmt:: Debug + ?Sized > (
@@ -221,6 +220,8 @@ pub fn assert_matches_failed<T: fmt::Debug + ?Sized>(
221
220
}
222
221
223
222
/// 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) ]
224
225
#[ track_caller]
225
226
fn assert_failed_inner (
226
227
kind : AssertKind ,
0 commit comments