diff options
| author | Ben Kimock <kimockb@gmail.com> | 2024-08-25 14:52:53 -0400 |
|---|---|---|
| committer | Ben Kimock <kimockb@gmail.com> | 2024-08-25 14:52:53 -0400 |
| commit | b1c2c78d297029c610ed00d757c90739a59f2d2d (patch) | |
| tree | 207f2e1fa66b20a0c0db2b12b56f47bd78a3c731 | |
| parent | 1a94d839be8b248b972b9e022cb940d56de72fa1 (diff) | |
| download | rust-b1c2c78d297029c610ed00d757c90739a59f2d2d.tar.gz rust-b1c2c78d297029c610ed00d757c90739a59f2d2d.zip | |
Tweak some attributes to improve panic_immediate_abort
| -rw-r--r-- | library/core/src/panic/location.rs | 1 | ||||
| -rw-r--r-- | library/core/src/slice/mod.rs | 4 | ||||
| -rw-r--r-- | library/core/src/slice/sort/shared/smallsort.rs | 3 |
3 files changed, 5 insertions, 3 deletions
diff --git a/library/core/src/panic/location.rs b/library/core/src/panic/location.rs index 930edffd505..e2a842046a9 100644 --- a/library/core/src/panic/location.rs +++ b/library/core/src/panic/location.rs @@ -195,6 +195,7 @@ impl<'a> Location<'a> { #[stable(feature = "panic_hook_display", since = "1.26.0")] impl fmt::Display for Location<'_> { + #[inline] fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { write!(formatter, "{}:{}:{}", self.file, self.line, self.col) } diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index c76157720b7..c7918499d4a 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -3667,8 +3667,8 @@ impl<T> [T] { { // The panic code path was put into a cold function to not bloat the // call site. - #[inline(never)] - #[cold] + #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)] + #[cfg_attr(feature = "panic_immediate_abort", inline)] #[track_caller] fn len_mismatch_fail(dst_len: usize, src_len: usize) -> ! { panic!( diff --git a/library/core/src/slice/sort/shared/smallsort.rs b/library/core/src/slice/sort/shared/smallsort.rs index db0c5c72822..fae628a7c14 100644 --- a/library/core/src/slice/sort/shared/smallsort.rs +++ b/library/core/src/slice/sort/shared/smallsort.rs @@ -840,7 +840,8 @@ unsafe fn bidirectional_merge<T: FreezeMarker, F: FnMut(&T, &T) -> bool>( } } -#[inline(never)] +#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)] +#[cfg_attr(feature = "panic_immediate_abort", inline)] fn panic_on_ord_violation() -> ! { // This is indicative of a logic bug in the user-provided comparison function or Ord // implementation. They are expected to implement a total order as explained in the Ord |
