@@ -40,13 +40,13 @@ use fmt;
40
40
use panic:: { Location , PanicInfo } ;
41
41
42
42
#[ 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) ) ]
45
45
#[ lang = "panic" ]
46
46
pub fn panic ( expr_file_line_col : & ( & ' static str , & ' static str , u32 , u32 ) ) -> ! {
47
47
if cfg ! ( feature = "panic_immediate_abort" ) {
48
48
unsafe { super :: intrinsics:: abort ( ) }
49
- } ;
49
+ }
50
50
51
51
// Use Arguments::new_v1 instead of format_args!("{}", expr) to potentially
52
52
// 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)) -> ! {
59
59
}
60
60
61
61
#[ 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) ) ]
64
63
#[ lang = "panic_bounds_check" ]
65
64
fn panic_bounds_check ( file_line_col : & ( & ' static str , u32 , u32 ) ,
66
65
index : usize , len : usize ) -> ! {
67
66
if cfg ! ( feature = "panic_immediate_abort" ) {
68
67
unsafe { super :: intrinsics:: abort ( ) }
69
- } ;
68
+ }
70
69
71
70
panic_fmt ( format_args ! ( "index out of bounds: the len is {} but the index is {}" ,
72
71
len, index) , file_line_col)
@@ -78,7 +77,7 @@ fn panic_bounds_check(file_line_col: &(&'static str, u32, u32),
78
77
pub fn panic_fmt ( fmt : fmt:: Arguments , file_line_col : & ( & ' static str , u32 , u32 ) ) -> ! {
79
78
if cfg ! ( feature = "panic_immediate_abort" ) {
80
79
unsafe { super :: intrinsics:: abort ( ) }
81
- } ;
80
+ }
82
81
83
82
// NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call
84
83
#[ allow( improper_ctypes) ] // PanicInfo contains a trait object which is not FFI safe
0 commit comments