Skip to content

Commit 41ac43f

Browse files
committed
Auto merge of rust-lang#129589 - saethlin:improve-panic-immediate-abort, r=tgross35
Tweak some attributes to improve panic_immediate_abort This is similar to rust-lang#117332; I did the same approach as before where I build a really big project with `-Zbuild-std -Zbuild-std-features=panic_immediate_abort` and grep its symbols for things that look panic-related.
2 parents 748c548 + b1c2c78 commit 41ac43f

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

library/core/src/panic/location.rs

+1
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
}

library/core/src/slice/mod.rs

+2-2
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!(

library/core/src/slice/sort/shared/smallsort.rs

+2-1
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

0 commit comments

Comments
 (0)