Skip to content

Commit

Permalink
Auto merge of rust-lang#121369 - saethlin:inline-slice-indexing, r=<try>
Browse files Browse the repository at this point in the history
Tweak inlining attributes for slice indexing

Doing some experiments in response to this unexpected regression: rust-lang#120863 (comment)

I expect the opt changes to be addressed by something like reviving rust-lang#91222. The debug changes are what I'm interested in.

Codegen tests will probably fail from time to time in this PR, I will fix them up later but also I don't trust the opt-level-z one: rust-lang#119878 (comment)

r? `@ghost`
  • Loading branch information
bors committed Feb 20, 2024
2 parents bb59453 + 574235c commit 4c5b313
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions library/core/src/slice/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ where
{
type Output = I::Output;

#[inline(always)]
#[inline]
fn index(&self, index: I) -> &I::Output {
index.index(self)
}
Expand All @@ -24,7 +24,7 @@ impl<T, I> ops::IndexMut<I> for [T]
where
I: SliceIndex<[T]>,
{
#[inline(always)]
#[inline]
fn index_mut(&mut self, index: I) -> &mut I::Output {
index.index_mut(self)
}
Expand Down Expand Up @@ -390,7 +390,7 @@ unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
}
}

#[inline(always)]
#[inline]
fn index(self, slice: &[T]) -> &[T] {
if self.start > self.end {
slice_index_order_fail(self.start, self.end);
Expand Down Expand Up @@ -440,7 +440,7 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeTo<usize> {
unsafe { (0..self.end).get_unchecked_mut(slice) }
}

#[inline(always)]
#[inline]
fn index(self, slice: &[T]) -> &[T] {
(0..self.end).index(slice)
}
Expand Down

0 comments on commit 4c5b313

Please sign in to comment.