diff --git a/library/core/src/slice/iter.rs b/library/core/src/slice/iter.rs index a687ed7129d..d48248749c2 100644 --- a/library/core/src/slice/iter.rs +++ b/library/core/src/slice/iter.rs @@ -93,9 +93,9 @@ unsafe impl Send for Iter<'_, T> {} impl<'a, T> Iter<'a, T> { #[inline] - pub(super) fn new(slice: &'a [T]) -> Self { + pub(super) const fn new(slice: &'a [T]) -> Self { let len = slice.len(); - let ptr: NonNull = NonNull::from(slice).cast(); + let ptr: NonNull = NonNull::from_ref(slice).cast(); // SAFETY: Similar to `IterMut::new`. unsafe { let end_or_len = @@ -218,9 +218,9 @@ unsafe impl Send for IterMut<'_, T> {} impl<'a, T> IterMut<'a, T> { #[inline] - pub(super) fn new(slice: &'a mut [T]) -> Self { + pub(super) const fn new(slice: &'a mut [T]) -> Self { let len = slice.len(); - let ptr: NonNull = NonNull::from(slice).cast(); + let ptr: NonNull = NonNull::from_mut(slice).cast(); // SAFETY: There are several things here: // // `ptr` has been obtained by `slice.as_ptr()` where `slice` is a valid @@ -1335,7 +1335,7 @@ pub struct Windows<'a, T: 'a> { impl<'a, T: 'a> Windows<'a, T> { #[inline] - pub(super) fn new(slice: &'a [T], size: NonZero) -> Self { + pub(super) const fn new(slice: &'a [T], size: NonZero) -> Self { Self { v: slice, size } } } @@ -1487,7 +1487,7 @@ pub struct Chunks<'a, T: 'a> { impl<'a, T: 'a> Chunks<'a, T> { #[inline] - pub(super) fn new(slice: &'a [T], size: usize) -> Self { + pub(super) const fn new(slice: &'a [T], size: usize) -> Self { Self { v: slice, chunk_size: size } } } @@ -1677,7 +1677,7 @@ pub struct ChunksMut<'a, T: 'a> { impl<'a, T: 'a> ChunksMut<'a, T> { #[inline] - pub(super) fn new(slice: &'a mut [T], size: usize) -> Self { + pub(super) const fn new(slice: &'a mut [T], size: usize) -> Self { Self { v: slice, chunk_size: size, _marker: PhantomData } } } @@ -1863,7 +1863,7 @@ pub struct ChunksExact<'a, T: 'a> { impl<'a, T> ChunksExact<'a, T> { #[inline] - pub(super) fn new(slice: &'a [T], chunk_size: usize) -> Self { + pub(super) const fn new(slice: &'a [T], chunk_size: usize) -> Self { let rem = slice.len() % chunk_size; let fst_len = slice.len() - rem; // SAFETY: 0 <= fst_len <= slice.len() by construction above @@ -2043,7 +2043,7 @@ pub struct ChunksExactMut<'a, T: 'a> { impl<'a, T> ChunksExactMut<'a, T> { #[inline] - pub(super) fn new(slice: &'a mut [T], chunk_size: usize) -> Self { + pub(super) const fn new(slice: &'a mut [T], chunk_size: usize) -> Self { let rem = slice.len() % chunk_size; let fst_len = slice.len() - rem; // SAFETY: 0 <= fst_len <= slice.len() by construction above @@ -2210,7 +2210,7 @@ pub struct ArrayWindows<'a, T: 'a, const N: usize> { impl<'a, T: 'a, const N: usize> ArrayWindows<'a, T, N> { #[inline] - pub(super) fn new(slice: &'a [T]) -> Self { + pub(super) const fn new(slice: &'a [T]) -> Self { let num_windows = slice.len().saturating_sub(N - 1); Self { slice_head: slice.as_ptr(), num: num_windows, marker: PhantomData } } @@ -2334,8 +2334,10 @@ pub struct ArrayChunks<'a, T: 'a, const N: usize> { } impl<'a, T, const N: usize> ArrayChunks<'a, T, N> { + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] + // #[rustc_const_unstable(feature = "slice_as_chunks", issue = "74985")] #[inline] - pub(super) fn new(slice: &'a [T]) -> Self { + pub(super) const fn new(slice: &'a [T]) -> Self { let (array_slice, rem) = slice.as_chunks(); Self { iter: array_slice.iter(), rem } } @@ -2460,8 +2462,9 @@ pub struct ArrayChunksMut<'a, T: 'a, const N: usize> { } impl<'a, T, const N: usize> ArrayChunksMut<'a, T, N> { + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] - pub(super) fn new(slice: &'a mut [T]) -> Self { + pub(super) const fn new(slice: &'a mut [T]) -> Self { let (array_slice, rem) = slice.as_chunks_mut(); Self { iter: array_slice.iter_mut(), rem } } @@ -2579,7 +2582,7 @@ pub struct RChunks<'a, T: 'a> { impl<'a, T: 'a> RChunks<'a, T> { #[inline] - pub(super) fn new(slice: &'a [T], size: usize) -> Self { + pub(super) const fn new(slice: &'a [T], size: usize) -> Self { Self { v: slice, chunk_size: size } } } @@ -2759,7 +2762,7 @@ pub struct RChunksMut<'a, T: 'a> { impl<'a, T: 'a> RChunksMut<'a, T> { #[inline] - pub(super) fn new(slice: &'a mut [T], size: usize) -> Self { + pub(super) const fn new(slice: &'a mut [T], size: usize) -> Self { Self { v: slice, chunk_size: size, _marker: PhantomData } } } @@ -2950,7 +2953,7 @@ pub struct RChunksExact<'a, T: 'a> { impl<'a, T> RChunksExact<'a, T> { #[inline] - pub(super) fn new(slice: &'a [T], chunk_size: usize) -> Self { + pub(super) const fn new(slice: &'a [T], chunk_size: usize) -> Self { let rem = slice.len() % chunk_size; // SAFETY: 0 <= rem <= slice.len() by construction above let (fst, snd) = unsafe { slice.split_at_unchecked(rem) }; @@ -2976,7 +2979,8 @@ impl<'a, T> RChunksExact<'a, T> { /// ``` #[must_use] #[stable(feature = "rchunks", since = "1.31.0")] - pub fn remainder(&self) -> &'a [T] { + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] + pub const fn remainder(&self) -> &'a [T] { self.rem } } @@ -3132,7 +3136,7 @@ pub struct RChunksExactMut<'a, T: 'a> { impl<'a, T> RChunksExactMut<'a, T> { #[inline] - pub(super) fn new(slice: &'a mut [T], chunk_size: usize) -> Self { + pub(super) const fn new(slice: &'a mut [T], chunk_size: usize) -> Self { let rem = slice.len() % chunk_size; // SAFETY: 0 <= rem <= slice.len() by construction above let (fst, snd) = unsafe { slice.split_at_mut_unchecked(rem) }; @@ -3144,7 +3148,8 @@ impl<'a, T> RChunksExactMut<'a, T> { /// elements. #[must_use = "`self` will be dropped if the result is not used"] #[stable(feature = "rchunks", since = "1.31.0")] - pub fn into_remainder(self) -> &'a mut [T] { + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] + pub const fn into_remainder(self) -> &'a mut [T] { self.rem } } @@ -3308,7 +3313,7 @@ pub struct ChunkBy<'a, T: 'a, P> { #[stable(feature = "slice_group_by", since = "1.77.0")] impl<'a, T: 'a, P> ChunkBy<'a, T, P> { - pub(super) fn new(slice: &'a [T], predicate: P) -> Self { + pub(super) const fn new(slice: &'a [T], predicate: P) -> Self { ChunkBy { slice, predicate } } } @@ -3395,7 +3400,7 @@ pub struct ChunkByMut<'a, T: 'a, P> { #[stable(feature = "slice_group_by", since = "1.77.0")] impl<'a, T: 'a, P> ChunkByMut<'a, T, P> { - pub(super) fn new(slice: &'a mut [T], predicate: P) -> Self { + pub(super) const fn new(slice: &'a mut [T], predicate: P) -> Self { ChunkByMut { slice, predicate } } } diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 5bb7243c449..ef8fb694a32 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -1043,9 +1043,10 @@ impl [T] { /// assert_eq!(iterator.next(), None); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] #[rustc_diagnostic_item = "slice_iter"] - pub fn iter(&self) -> Iter<'_, T> { + pub const fn iter(&self) -> Iter<'_, T> { Iter::new(self) } @@ -1062,9 +1063,10 @@ impl [T] { /// } /// assert_eq!(x, &[3, 4, 6]); /// ``` + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn iter_mut(&mut self) -> IterMut<'_, T> { + pub const fn iter_mut(&mut self) -> IterMut<'_, T> { IterMut::new(self) } @@ -1116,9 +1118,10 @@ impl [T] { /// assert_eq!(array, ['s', 't', ' ', '2', '0', '1', '5', 'u', 'R']); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] #[track_caller] - pub fn windows(&self, size: usize) -> Windows<'_, T> { + pub const fn windows(&self, size: usize) -> Windows<'_, T> { let size = NonZero::new(size).expect("window size must be non-zero"); Windows::new(self, size) } @@ -1151,9 +1154,10 @@ impl [T] { /// [`chunks_exact`]: slice::chunks_exact /// [`rchunks`]: slice::rchunks #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] #[track_caller] - pub fn chunks(&self, chunk_size: usize) -> Chunks<'_, T> { + pub const fn chunks(&self, chunk_size: usize) -> Chunks<'_, T> { assert!(chunk_size != 0, "chunk size must be non-zero"); Chunks::new(self, chunk_size) } @@ -1190,9 +1194,10 @@ impl [T] { /// [`chunks_exact_mut`]: slice::chunks_exact_mut /// [`rchunks_mut`]: slice::rchunks_mut #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] #[track_caller] - pub fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<'_, T> { + pub const fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<'_, T> { assert!(chunk_size != 0, "chunk size must be non-zero"); ChunksMut::new(self, chunk_size) } @@ -1228,9 +1233,10 @@ impl [T] { /// [`chunks`]: slice::chunks /// [`rchunks_exact`]: slice::rchunks_exact #[stable(feature = "chunks_exact", since = "1.31.0")] + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] #[track_caller] - pub fn chunks_exact(&self, chunk_size: usize) -> ChunksExact<'_, T> { + pub const fn chunks_exact(&self, chunk_size: usize) -> ChunksExact<'_, T> { assert!(chunk_size != 0, "chunk size must be non-zero"); ChunksExact::new(self, chunk_size) } @@ -1271,9 +1277,10 @@ impl [T] { /// [`chunks_mut`]: slice::chunks_mut /// [`rchunks_exact_mut`]: slice::rchunks_exact_mut #[stable(feature = "chunks_exact", since = "1.31.0")] + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] #[track_caller] - pub fn chunks_exact_mut(&mut self, chunk_size: usize) -> ChunksExactMut<'_, T> { + pub const fn chunks_exact_mut(&mut self, chunk_size: usize) -> ChunksExactMut<'_, T> { assert!(chunk_size != 0, "chunk size must be non-zero"); ChunksExactMut::new(self, chunk_size) } @@ -1429,9 +1436,10 @@ impl [T] { /// /// [`chunks_exact`]: slice::chunks_exact #[unstable(feature = "array_chunks", issue = "74985")] + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] #[track_caller] - pub fn array_chunks(&self) -> ArrayChunks<'_, T, N> { + pub const fn array_chunks(&self) -> ArrayChunks<'_, T, N> { assert!(N != 0, "chunk size must be non-zero"); ArrayChunks::new(self) } @@ -1592,9 +1600,10 @@ impl [T] { /// /// [`chunks_exact_mut`]: slice::chunks_exact_mut #[unstable(feature = "array_chunks", issue = "74985")] + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] #[track_caller] - pub fn array_chunks_mut(&mut self) -> ArrayChunksMut<'_, T, N> { + pub const fn array_chunks_mut(&mut self) -> ArrayChunksMut<'_, T, N> { assert!(N != 0, "chunk size must be non-zero"); ArrayChunksMut::new(self) } @@ -1625,9 +1634,10 @@ impl [T] { /// /// [`windows`]: slice::windows #[unstable(feature = "array_windows", issue = "75027")] + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] #[track_caller] - pub fn array_windows(&self) -> ArrayWindows<'_, T, N> { + pub const fn array_windows(&self) -> ArrayWindows<'_, T, N> { assert!(N != 0, "window size must be non-zero"); ArrayWindows::new(self) } @@ -1660,9 +1670,10 @@ impl [T] { /// [`rchunks_exact`]: slice::rchunks_exact /// [`chunks`]: slice::chunks #[stable(feature = "rchunks", since = "1.31.0")] + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] #[track_caller] - pub fn rchunks(&self, chunk_size: usize) -> RChunks<'_, T> { + pub const fn rchunks(&self, chunk_size: usize) -> RChunks<'_, T> { assert!(chunk_size != 0, "chunk size must be non-zero"); RChunks::new(self, chunk_size) } @@ -1699,9 +1710,10 @@ impl [T] { /// [`rchunks_exact_mut`]: slice::rchunks_exact_mut /// [`chunks_mut`]: slice::chunks_mut #[stable(feature = "rchunks", since = "1.31.0")] + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] #[track_caller] - pub fn rchunks_mut(&mut self, chunk_size: usize) -> RChunksMut<'_, T> { + pub const fn rchunks_mut(&mut self, chunk_size: usize) -> RChunksMut<'_, T> { assert!(chunk_size != 0, "chunk size must be non-zero"); RChunksMut::new(self, chunk_size) } @@ -1739,9 +1751,10 @@ impl [T] { /// [`rchunks`]: slice::rchunks /// [`chunks_exact`]: slice::chunks_exact #[stable(feature = "rchunks", since = "1.31.0")] + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] #[track_caller] - pub fn rchunks_exact(&self, chunk_size: usize) -> RChunksExact<'_, T> { + pub const fn rchunks_exact(&self, chunk_size: usize) -> RChunksExact<'_, T> { assert!(chunk_size != 0, "chunk size must be non-zero"); RChunksExact::new(self, chunk_size) } @@ -1783,9 +1796,10 @@ impl [T] { /// [`rchunks_mut`]: slice::rchunks_mut /// [`chunks_exact_mut`]: slice::chunks_exact_mut #[stable(feature = "rchunks", since = "1.31.0")] + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] #[track_caller] - pub fn rchunks_exact_mut(&mut self, chunk_size: usize) -> RChunksExactMut<'_, T> { + pub const fn rchunks_exact_mut(&mut self, chunk_size: usize) -> RChunksExactMut<'_, T> { assert!(chunk_size != 0, "chunk size must be non-zero"); RChunksExactMut::new(self, chunk_size) } @@ -1823,8 +1837,9 @@ impl [T] { /// assert_eq!(iter.next(), None); /// ``` #[stable(feature = "slice_group_by", since = "1.77.0")] + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] - pub fn chunk_by(&self, pred: F) -> ChunkBy<'_, T, F> + pub const fn chunk_by(&self, pred: F) -> ChunkBy<'_, T, F> where F: FnMut(&T, &T) -> bool, { @@ -1864,8 +1879,9 @@ impl [T] { /// assert_eq!(iter.next(), None); /// ``` #[stable(feature = "slice_group_by", since = "1.77.0")] + #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] - pub fn chunk_by_mut(&mut self, pred: F) -> ChunkByMut<'_, T, F> + pub const fn chunk_by_mut(&mut self, pred: F) -> ChunkByMut<'_, T, F> where F: FnMut(&T, &T) -> bool, { diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir index 7ef532d222d..c75edde711e 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir @@ -22,74 +22,74 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug i => _33; debug x => _34; } - scope 19 (inlined > as Iterator>::next) { + scope 18 (inlined > as Iterator>::next) { let mut _27: std::option::Option<&T>; let mut _30: (usize, bool); let mut _31: (usize, &T); - scope 20 { + scope 19 { let _29: usize; - scope 25 { - } - } - scope 21 { - scope 22 { - scope 28 (inlined as FromResidual>>::from_residual) { - } - } - } - scope 23 { scope 24 { } } - scope 26 (inlined as Try>::branch) { - let _28: &T; - scope 27 { + scope 20 { + scope 21 { + scope 27 (inlined as FromResidual>>::from_residual) { + } } } - scope 29 (inlined as Iterator>::next) { + scope 22 { + scope 23 { + } + } + scope 25 (inlined as Try>::branch) { + let _28: &T; + scope 26 { + } + } + scope 28 (inlined as Iterator>::next) { let _14: std::ptr::NonNull; let _16: std::ptr::NonNull; let mut _19: bool; let mut _22: std::ptr::NonNull; let mut _24: usize; let _26: &T; - scope 30 { + scope 29 { let _15: *const T; - scope 31 { + scope 30 { let _23: usize; - scope 32 { - scope 35 (inlined core::num::::unchecked_sub) { - scope 36 (inlined core::ub_checks::check_language_ub) { - scope 37 (inlined core::ub_checks::check_language_ub::runtime) { + scope 31 { + scope 34 (inlined core::num::::unchecked_sub) { + scope 35 (inlined core::ub_checks::check_language_ub) { + scope 36 (inlined core::ub_checks::check_language_ub::runtime) { } } } - scope 38 (inlined without_provenance_mut::) { + scope 37 (inlined without_provenance_mut::) { } } - scope 33 (inlined std::ptr::const_ptr::::addr) { - scope 34 (inlined std::ptr::const_ptr::::cast::<()>) { + scope 32 (inlined std::ptr::const_ptr::::addr) { + scope 33 (inlined std::ptr::const_ptr::::cast::<()>) { } } - scope 39 (inlined as PartialEq>::eq) { + scope 38 (inlined as PartialEq>::eq) { let mut _17: *mut T; let mut _18: *mut T; + scope 39 (inlined NonNull::::as_ptr) { + } scope 40 (inlined NonNull::::as_ptr) { } - scope 41 (inlined NonNull::::as_ptr) { - } } - scope 42 (inlined NonNull::::add) { + scope 41 (inlined NonNull::::add) { let mut _20: *const T; let mut _21: *const T; - scope 43 (inlined NonNull::::as_ptr) { + scope 42 (inlined NonNull::::as_ptr) { } } - scope 44 (inlined NonNull::::as_ref::<'_>) { + scope 43 (inlined NonNull::::as_ref::<'_>) { let _25: *const T; - scope 45 (inlined NonNull::::as_ptr) { + scope 44 (inlined NonNull::::as_ptr) { } - scope 46 (inlined std::ptr::mut_ptr::::cast_const) { + scope 45 (inlined std::ptr::mut_ptr::::cast_const) { } } } @@ -109,33 +109,31 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let _9: *const T; scope 7 { } - scope 12 (inlined std::ptr::without_provenance::) { - scope 13 (inlined without_provenance_mut::) { + scope 11 (inlined std::ptr::without_provenance::) { + scope 12 (inlined without_provenance_mut::) { } } - scope 14 (inlined NonNull::::as_ptr) { + scope 13 (inlined NonNull::::as_ptr) { } - scope 15 (inlined std::ptr::mut_ptr::::add) { + scope 14 (inlined std::ptr::mut_ptr::::add) { } } - scope 8 (inlined as From<&[T]>>::from) { - scope 9 (inlined NonNull::<[T]>::from_ref) { - let mut _4: *const [T]; - } + scope 8 (inlined NonNull::<[T]>::from_ref) { + let mut _4: *const [T]; } - scope 10 (inlined NonNull::<[T]>::cast::) { + scope 9 (inlined NonNull::<[T]>::cast::) { let mut _5: *const T; - scope 11 (inlined NonNull::<[T]>::as_ptr) { + scope 10 (inlined NonNull::<[T]>::as_ptr) { } } } } } - scope 16 (inlined as Iterator>::enumerate) { - scope 17 (inlined Enumerate::>::new) { + scope 15 (inlined as Iterator>::enumerate) { + scope 16 (inlined Enumerate::>::new) { } } - scope 18 (inlined > as IntoIterator>::into_iter) { + scope 17 (inlined > as IntoIterator>::into_iter) { } bb0: { diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir index 33dbf04d028..bc72181b77c 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir @@ -34,33 +34,31 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let _9: *const T; scope 7 { } - scope 12 (inlined std::ptr::without_provenance::) { - scope 13 (inlined without_provenance_mut::) { + scope 11 (inlined std::ptr::without_provenance::) { + scope 12 (inlined without_provenance_mut::) { } } - scope 14 (inlined NonNull::::as_ptr) { + scope 13 (inlined NonNull::::as_ptr) { } - scope 15 (inlined std::ptr::mut_ptr::::add) { + scope 14 (inlined std::ptr::mut_ptr::::add) { } } - scope 8 (inlined as From<&[T]>>::from) { - scope 9 (inlined NonNull::<[T]>::from_ref) { - let mut _4: *const [T]; - } + scope 8 (inlined NonNull::<[T]>::from_ref) { + let mut _4: *const [T]; } - scope 10 (inlined NonNull::<[T]>::cast::) { + scope 9 (inlined NonNull::<[T]>::cast::) { let mut _5: *const T; - scope 11 (inlined NonNull::<[T]>::as_ptr) { + scope 10 (inlined NonNull::<[T]>::as_ptr) { } } } } } - scope 16 (inlined as Iterator>::enumerate) { - scope 17 (inlined Enumerate::>::new) { + scope 15 (inlined as Iterator>::enumerate) { + scope 16 (inlined Enumerate::>::new) { } } - scope 18 (inlined > as IntoIterator>::into_iter) { + scope 17 (inlined > as IntoIterator>::into_iter) { } bb0: { diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir index 62787f3447c..38c509d0b53 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -18,50 +18,50 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 2 { debug x => _27; } - scope 17 (inlined as Iterator>::next) { + scope 16 (inlined as Iterator>::next) { let _13: std::ptr::NonNull; let _15: std::ptr::NonNull; let mut _18: bool; let mut _21: std::ptr::NonNull; let mut _23: usize; let _25: &T; - scope 18 { + scope 17 { let _14: *const T; - scope 19 { + scope 18 { let _22: usize; - scope 20 { - scope 23 (inlined core::num::::unchecked_sub) { - scope 24 (inlined core::ub_checks::check_language_ub) { - scope 25 (inlined core::ub_checks::check_language_ub::runtime) { + scope 19 { + scope 22 (inlined core::num::::unchecked_sub) { + scope 23 (inlined core::ub_checks::check_language_ub) { + scope 24 (inlined core::ub_checks::check_language_ub::runtime) { } } } - scope 26 (inlined without_provenance_mut::) { + scope 25 (inlined without_provenance_mut::) { } } - scope 21 (inlined std::ptr::const_ptr::::addr) { - scope 22 (inlined std::ptr::const_ptr::::cast::<()>) { + scope 20 (inlined std::ptr::const_ptr::::addr) { + scope 21 (inlined std::ptr::const_ptr::::cast::<()>) { } } - scope 27 (inlined as PartialEq>::eq) { + scope 26 (inlined as PartialEq>::eq) { let mut _16: *mut T; let mut _17: *mut T; + scope 27 (inlined NonNull::::as_ptr) { + } scope 28 (inlined NonNull::::as_ptr) { } - scope 29 (inlined NonNull::::as_ptr) { - } } - scope 30 (inlined NonNull::::add) { + scope 29 (inlined NonNull::::add) { let mut _19: *const T; let mut _20: *const T; - scope 31 (inlined NonNull::::as_ptr) { + scope 30 (inlined NonNull::::as_ptr) { } } - scope 32 (inlined NonNull::::as_ref::<'_>) { + scope 31 (inlined NonNull::::as_ref::<'_>) { let _24: *const T; - scope 33 (inlined NonNull::::as_ptr) { + scope 32 (inlined NonNull::::as_ptr) { } - scope 34 (inlined std::ptr::mut_ptr::::cast_const) { + scope 33 (inlined std::ptr::mut_ptr::::cast_const) { } } } @@ -80,29 +80,27 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { let _9: *const T; scope 7 { } - scope 12 (inlined std::ptr::without_provenance::) { - scope 13 (inlined without_provenance_mut::) { + scope 11 (inlined std::ptr::without_provenance::) { + scope 12 (inlined without_provenance_mut::) { } } - scope 14 (inlined NonNull::::as_ptr) { + scope 13 (inlined NonNull::::as_ptr) { } - scope 15 (inlined std::ptr::mut_ptr::::add) { + scope 14 (inlined std::ptr::mut_ptr::::add) { } } - scope 8 (inlined as From<&[T]>>::from) { - scope 9 (inlined NonNull::<[T]>::from_ref) { - let mut _4: *const [T]; - } + scope 8 (inlined NonNull::<[T]>::from_ref) { + let mut _4: *const [T]; } - scope 10 (inlined NonNull::<[T]>::cast::) { + scope 9 (inlined NonNull::<[T]>::cast::) { let mut _5: *const T; - scope 11 (inlined NonNull::<[T]>::as_ptr) { + scope 10 (inlined NonNull::<[T]>::as_ptr) { } } } } } - scope 16 (inlined as IntoIterator>::into_iter) { + scope 15 (inlined as IntoIterator>::into_iter) { } bb0: { diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir index e5478e27918..158cc284b1a 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -18,50 +18,50 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 2 { debug x => _27; } - scope 17 (inlined as Iterator>::next) { + scope 16 (inlined as Iterator>::next) { let _13: std::ptr::NonNull; let _15: std::ptr::NonNull; let mut _18: bool; let mut _21: std::ptr::NonNull; let mut _23: usize; let _25: &T; - scope 18 { + scope 17 { let _14: *const T; - scope 19 { + scope 18 { let _22: usize; - scope 20 { - scope 23 (inlined core::num::::unchecked_sub) { - scope 24 (inlined core::ub_checks::check_language_ub) { - scope 25 (inlined core::ub_checks::check_language_ub::runtime) { + scope 19 { + scope 22 (inlined core::num::::unchecked_sub) { + scope 23 (inlined core::ub_checks::check_language_ub) { + scope 24 (inlined core::ub_checks::check_language_ub::runtime) { } } } - scope 26 (inlined without_provenance_mut::) { + scope 25 (inlined without_provenance_mut::) { } } - scope 21 (inlined std::ptr::const_ptr::::addr) { - scope 22 (inlined std::ptr::const_ptr::::cast::<()>) { + scope 20 (inlined std::ptr::const_ptr::::addr) { + scope 21 (inlined std::ptr::const_ptr::::cast::<()>) { } } - scope 27 (inlined as PartialEq>::eq) { + scope 26 (inlined as PartialEq>::eq) { let mut _16: *mut T; let mut _17: *mut T; + scope 27 (inlined NonNull::::as_ptr) { + } scope 28 (inlined NonNull::::as_ptr) { } - scope 29 (inlined NonNull::::as_ptr) { - } } - scope 30 (inlined NonNull::::add) { + scope 29 (inlined NonNull::::add) { let mut _19: *const T; let mut _20: *const T; - scope 31 (inlined NonNull::::as_ptr) { + scope 30 (inlined NonNull::::as_ptr) { } } - scope 32 (inlined NonNull::::as_ref::<'_>) { + scope 31 (inlined NonNull::::as_ref::<'_>) { let _24: *const T; - scope 33 (inlined NonNull::::as_ptr) { + scope 32 (inlined NonNull::::as_ptr) { } - scope 34 (inlined std::ptr::mut_ptr::::cast_const) { + scope 33 (inlined std::ptr::mut_ptr::::cast_const) { } } } @@ -80,29 +80,27 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { let _9: *const T; scope 7 { } - scope 12 (inlined std::ptr::without_provenance::) { - scope 13 (inlined without_provenance_mut::) { + scope 11 (inlined std::ptr::without_provenance::) { + scope 12 (inlined without_provenance_mut::) { } } - scope 14 (inlined NonNull::::as_ptr) { + scope 13 (inlined NonNull::::as_ptr) { } - scope 15 (inlined std::ptr::mut_ptr::::add) { + scope 14 (inlined std::ptr::mut_ptr::::add) { } } - scope 8 (inlined as From<&[T]>>::from) { - scope 9 (inlined NonNull::<[T]>::from_ref) { - let mut _4: *const [T]; - } + scope 8 (inlined NonNull::<[T]>::from_ref) { + let mut _4: *const [T]; } - scope 10 (inlined NonNull::<[T]>::cast::) { + scope 9 (inlined NonNull::<[T]>::cast::) { let mut _5: *const T; - scope 11 (inlined NonNull::<[T]>::as_ptr) { + scope 10 (inlined NonNull::<[T]>::as_ptr) { } } } } } - scope 16 (inlined as IntoIterator>::into_iter) { + scope 15 (inlined as IntoIterator>::into_iter) { } bb0: { diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir index 4b7ab4516d2..00366762108 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir @@ -18,7 +18,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 2 { debug x => _17; } - scope 19 (inlined > as Iterator>::next) { + scope 18 (inlined > as Iterator>::next) { let mut _14: &mut std::slice::Iter<'_, T>; } } @@ -34,33 +34,31 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { let _9: *const T; scope 7 { } - scope 12 (inlined std::ptr::without_provenance::) { - scope 13 (inlined without_provenance_mut::) { + scope 11 (inlined std::ptr::without_provenance::) { + scope 12 (inlined without_provenance_mut::) { } } - scope 14 (inlined NonNull::::as_ptr) { + scope 13 (inlined NonNull::::as_ptr) { } - scope 15 (inlined std::ptr::mut_ptr::::add) { + scope 14 (inlined std::ptr::mut_ptr::::add) { } } - scope 8 (inlined as From<&[T]>>::from) { - scope 9 (inlined NonNull::<[T]>::from_ref) { - let mut _4: *const [T]; - } + scope 8 (inlined NonNull::<[T]>::from_ref) { + let mut _4: *const [T]; } - scope 10 (inlined NonNull::<[T]>::cast::) { + scope 9 (inlined NonNull::<[T]>::cast::) { let mut _5: *const T; - scope 11 (inlined NonNull::<[T]>::as_ptr) { + scope 10 (inlined NonNull::<[T]>::as_ptr) { } } } } } - scope 16 (inlined as Iterator>::rev) { - scope 17 (inlined Rev::>::new) { + scope 15 (inlined as Iterator>::rev) { + scope 16 (inlined Rev::>::new) { } } - scope 18 (inlined > as IntoIterator>::into_iter) { + scope 17 (inlined > as IntoIterator>::into_iter) { } bb0: { diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir index b2c15247cd7..e1d710fb689 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir @@ -18,7 +18,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 2 { debug x => _17; } - scope 19 (inlined > as Iterator>::next) { + scope 18 (inlined > as Iterator>::next) { let mut _14: &mut std::slice::Iter<'_, T>; } } @@ -34,33 +34,31 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { let _9: *const T; scope 7 { } - scope 12 (inlined std::ptr::without_provenance::) { - scope 13 (inlined without_provenance_mut::) { + scope 11 (inlined std::ptr::without_provenance::) { + scope 12 (inlined without_provenance_mut::) { } } - scope 14 (inlined NonNull::::as_ptr) { + scope 13 (inlined NonNull::::as_ptr) { } - scope 15 (inlined std::ptr::mut_ptr::::add) { + scope 14 (inlined std::ptr::mut_ptr::::add) { } } - scope 8 (inlined as From<&[T]>>::from) { - scope 9 (inlined NonNull::<[T]>::from_ref) { - let mut _4: *const [T]; - } + scope 8 (inlined NonNull::<[T]>::from_ref) { + let mut _4: *const [T]; } - scope 10 (inlined NonNull::<[T]>::cast::) { + scope 9 (inlined NonNull::<[T]>::cast::) { let mut _5: *const T; - scope 11 (inlined NonNull::<[T]>::as_ptr) { + scope 10 (inlined NonNull::<[T]>::as_ptr) { } } } } } - scope 16 (inlined as Iterator>::rev) { - scope 17 (inlined Rev::>::new) { + scope 15 (inlined as Iterator>::rev) { + scope 16 (inlined Rev::>::new) { } } - scope 18 (inlined > as IntoIterator>::into_iter) { + scope 17 (inlined > as IntoIterator>::into_iter) { } bb0: {