@@ -40,13 +40,13 @@ use fmt;
4040use panic:: { Location , PanicInfo } ;
4141
4242#[ cold]
43- // inline( never) is required even in panic_immediate_abort mode, lest linker error
44- #[ inline( never) ]
43+ // never inline unless panic_immediate_abort to avoid code bloat at the call sites as much as possible
44+ #[ cfg_attr ( not ( feature= "panic_immediate_abort" ) , inline( never) ) ]
4545#[ lang = "panic" ]
4646pub fn panic ( expr_file_line_col : & ( & ' static str , & ' static str , u32 , u32 ) ) -> ! {
4747 if cfg ! ( feature = "panic_immediate_abort" ) {
4848 unsafe { super :: intrinsics:: abort ( ) }
49- } ;
49+ }
5050
5151 // Use Arguments::new_v1 instead of format_args!("{}", expr) to potentially
5252 // reduce size overhead. The format_args! macro uses str's Display trait to
@@ -59,14 +59,13 @@ pub fn panic(expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! {
5959}
6060
6161#[ cold]
62- // inline(never) is required even in panic_immediate_abort mode, lest linker error
63- #[ inline( never) ]
62+ #[ cfg_attr( not( feature="panic_immediate_abort" ) , inline( never) ) ]
6463#[ lang = "panic_bounds_check" ]
6564fn panic_bounds_check ( file_line_col : & ( & ' static str , u32 , u32 ) ,
6665 index : usize , len : usize ) -> ! {
6766 if cfg ! ( feature = "panic_immediate_abort" ) {
6867 unsafe { super :: intrinsics:: abort ( ) }
69- } ;
68+ }
7069
7170 panic_fmt ( format_args ! ( "index out of bounds: the len is {} but the index is {}" ,
7271 len, index) , file_line_col)
@@ -78,7 +77,7 @@ fn panic_bounds_check(file_line_col: &(&'static str, u32, u32),
7877pub fn panic_fmt ( fmt : fmt:: Arguments , file_line_col : & ( & ' static str , u32 , u32 ) ) -> ! {
7978 if cfg ! ( feature = "panic_immediate_abort" ) {
8079 unsafe { super :: intrinsics:: abort ( ) }
81- } ;
80+ }
8281
8382 // NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call
8483 #[ allow( improper_ctypes) ] // PanicInfo contains a trait object which is not FFI safe
0 commit comments