Skip to content

Commit 3cf9ae6

Browse files
committed
inline slice panics on panic_immediate_abort
1 parent 0b42dea commit 3cf9ae6

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

library/core/src/slice/index.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,40 @@ where
2727
}
2828
}
2929

30-
#[inline(never)]
30+
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
31+
#[cfg_attr(feature = "panic_immediate_abort", inline)]
3132
#[cold]
3233
#[track_caller]
3334
fn slice_start_index_len_fail(index: usize, len: usize) -> ! {
3435
panic!("range start index {} out of range for slice of length {}", index, len);
3536
}
3637

37-
#[inline(never)]
38+
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
39+
#[cfg_attr(feature = "panic_immediate_abort", inline)]
3840
#[cold]
3941
#[track_caller]
4042
fn slice_end_index_len_fail(index: usize, len: usize) -> ! {
4143
panic!("range end index {} out of range for slice of length {}", index, len);
4244
}
4345

44-
#[inline(never)]
46+
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
47+
#[cfg_attr(feature = "panic_immediate_abort", inline)]
4548
#[cold]
4649
#[track_caller]
4750
fn slice_index_order_fail(index: usize, end: usize) -> ! {
4851
panic!("slice index starts at {} but ends at {}", index, end);
4952
}
5053

51-
#[inline(never)]
54+
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
55+
#[cfg_attr(feature = "panic_immediate_abort", inline)]
5256
#[cold]
5357
#[track_caller]
5458
fn slice_start_index_overflow_fail() -> ! {
5559
panic!("attempted to index slice from after maximum usize");
5660
}
5761

58-
#[inline(never)]
62+
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
63+
#[cfg_attr(feature = "panic_immediate_abort", inline)]
5964
#[cold]
6065
#[track_caller]
6166
fn slice_end_index_overflow_fail() -> ! {

0 commit comments

Comments
 (0)