Tweak some attributes to improve panic_immediate_abort · patricklam/verify-rust-std@46eff20

3 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -195,6 +195,7 @@ impl<'a> Location<'a> {

195195
196196

#[stable(feature = "panic_hook_display", since = "1.26.0")]

197197

impl fmt::Display for Location<'_> {

198+

#[inline]

198199

fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {

199200

write!(formatter, "{}:{}:{}", self.file, self.line, self.col)

200201

}

Original file line numberDiff line numberDiff line change

@@ -3667,8 +3667,8 @@ impl<T> [T] {

36673667

{

36683668

// The panic code path was put into a cold function to not bloat the

36693669

// call site.

3670-

#[inline(never)]

3671-

#[cold]

3670+

#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)]

3671+

#[cfg_attr(feature = "panic_immediate_abort", inline)]

36723672

#[track_caller]

36733673

fn len_mismatch_fail(dst_len: usize, src_len: usize) -> ! {

36743674

panic!(

Original file line numberDiff line numberDiff line change

@@ -840,7 +840,8 @@ unsafe fn bidirectional_merge<T: FreezeMarker, F: FnMut(&T, &T) -> bool>(

840840

}

841841

}

842842
843-

#[inline(never)]

843+

#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)]

844+

#[cfg_attr(feature = "panic_immediate_abort", inline)]

844845

fn panic_on_ord_violation() -> ! {

845846

// This is indicative of a logic bug in the user-provided comparison function or Ord

846847

// implementation. They are expected to implement a total order as explained in the Ord