diff --git a/library/alloc/src/raw_vec/mod.rs b/library/alloc/src/raw_vec/mod.rs index ffc92056cf464..8b87bf017a779 100644 --- a/library/alloc/src/raw_vec/mod.rs +++ b/library/alloc/src/raw_vec/mod.rs @@ -6,7 +6,8 @@ use core::marker::{Destruct, PhantomData}; use core::mem::{Alignment, ManuallyDrop, MaybeUninit, SizedTypeProperties}; -use core::ptr::{self, NonNull, Unique}; +use core::panic::UnwindSafe; +use core::ptr::{self, NonNull}; use core::{cmp, hint}; #[cfg(not(no_global_oom_handling))] @@ -54,14 +55,16 @@ const unsafe fn new_cap(cap: usize) -> Cap { /// involved. This type is excellent for building your own data structures like Vec and VecDeque. /// In particular: /// -/// * Produces `Unique::dangling()` on zero-sized types. -/// * Produces `Unique::dangling()` on zero-length allocations. -/// * Avoids freeing `Unique::dangling()`. +/// * Produces `NonNull::dangling()` on zero-sized types. +/// * Produces `NonNull::dangling()` on zero-length allocations. +/// * Avoids freeing `NonNull::dangling()`. /// * Catches all overflows in capacity computations (promotes them to "capacity overflow" panics). /// * Guards against 32-bit systems allocating more than `isize::MAX` bytes. +/// * Provides niches for capacities greater than `isize::MAX`. /// * Guards against overflowing your length. /// * Calls `handle_alloc_error` for fallible allocations. -/// * Contains a `ptr::Unique` and thus endows the user with all related benefits. +/// * Implements `Send`, `Sync` and `UnwindSafe` iff `(T, A)` does. +/// * Carries `PhantomData` for auto trait and `may_dangle` correctness. /// * Uses the excess returned from the allocator to use the largest available capacity. /// /// This type does not in anyway inspect the memory that it manages. When dropped it *will* @@ -85,7 +88,7 @@ pub(crate) struct RawVec { /// as most operations don't need the actual type, just its layout. #[allow(missing_debug_implementations)] struct RawVecInner { - ptr: Unique, + ptr: NonNull, /// Never used for ZSTs; it's `capacity()`'s responsibility to return usize::MAX in that case. /// /// # Safety @@ -94,6 +97,9 @@ struct RawVecInner { cap: Cap, alloc: A, } +unsafe impl Send for RawVecInner {} +unsafe impl Sync for RawVecInner {} +impl UnwindSafe for RawVecInner {} impl RawVec { /// Creates the biggest possible `RawVec` (on the system heap) @@ -298,7 +304,7 @@ impl RawVec { } /// Gets a raw pointer to the start of the allocation. Note that this is - /// `Unique::dangling()` if `capacity == 0` or `T` is zero-sized. In the former case, you must + /// `NonNull::dangling()` if `capacity == 0` or `T` is zero-sized. In the former case, you must /// be careful. #[inline] pub(crate) const fn ptr(&self) -> *mut T { @@ -487,7 +493,7 @@ const impl RawVecInner { // matches the size requested. If that ever changes, the capacity // here should change to `ptr.len() / size_of::()`. Ok(Self { - ptr: Unique::from(ptr.cast()), + ptr: ptr.cast(), // SAFETY: We return early if `T` is a ZST, and if `capacity` would // overflow an isize layout creation would have returned early as well. cap: unsafe { Cap::new_unchecked(capacity) }, @@ -582,7 +588,7 @@ const impl RawVecInner { impl RawVecInner { #[inline] const fn new_in(alloc: A, align: Alignment) -> Self { - let ptr = Unique::from_non_null(NonNull::without_provenance(align.as_nonzero_usize())); + let ptr = NonNull::without_provenance(align.as_nonzero_usize()); // `cap: 0` means "unallocated". zero-sized types are ignored. Self { ptr, cap: ZERO_CAP, alloc } } @@ -608,13 +614,13 @@ impl RawVecInner { #[inline] const unsafe fn from_raw_parts_in(ptr: *mut u8, cap: Cap, alloc: A) -> Self { // SAFETY: Upheld by caller. - Self { ptr: unsafe { Unique::new_unchecked(ptr) }, cap, alloc } + Self { ptr: unsafe { NonNull::new_unchecked(ptr) }, cap, alloc } } #[inline] #[rustc_const_unstable(feature = "const_heap", issue = "79597")] const unsafe fn from_nonnull_in(ptr: NonNull, cap: Cap, alloc: A) -> Self { - Self { ptr: Unique::from(ptr), cap, alloc } + Self { ptr, cap, alloc } } #[inline] @@ -624,7 +630,7 @@ impl RawVecInner { #[inline] const fn non_null(&self) -> NonNull { - self.ptr.cast().as_non_null_ptr() + self.ptr.cast() } #[inline] @@ -793,7 +799,7 @@ impl RawVecInner { // Allocators currently return a `NonNull<[u8]>` whose length matches // the size requested. If that ever changes, the capacity here should // change to `ptr.len() / size_of::()`. - self.ptr = Unique::from(ptr.cast()); + self.ptr = ptr.cast(); // SAFETY: Upheld by caller. self.cap = unsafe { Cap::new_unchecked(cap) }; } @@ -865,9 +871,7 @@ impl RawVecInner { // SAFETY: T isn't a ZST if we're here and `ptr` is our pointer that `current_memory` // ensures was allocated with `layout`. unsafe { self.alloc.deallocate(ptr, layout) }; - self.ptr = - // SAFETY: Alignment is guaranteed to be nonzero. - unsafe { Unique::new_unchecked(ptr::without_provenance_mut(elem_layout.align())) }; + self.ptr = NonNull::without_provenance(elem_layout.alignment().as_nonzero_usize()); self.cap = ZERO_CAP; } else { // SAFETY: `cap` is less than the previous capacity, which must have fit in an diff --git a/library/alloc/src/raw_vec/tests.rs b/library/alloc/src/raw_vec/tests.rs index 15f48c03dc54c..f325f8b441b32 100644 --- a/library/alloc/src/raw_vec/tests.rs +++ b/library/alloc/src/raw_vec/tests.rs @@ -84,7 +84,7 @@ struct ZST; // A `RawVec` holding zero-sized elements should always look like this. fn zst_sanity(v: &RawVec) { assert_eq!(v.capacity(), usize::MAX); - assert_eq!(v.ptr(), core::ptr::Unique::::dangling().as_ptr()); + assert_eq!(v.ptr(), core::ptr::dangling_mut::()); assert_eq!(unsafe { v.inner.current_memory(T::LAYOUT) }, None); } diff --git a/library/alloctests/lib.rs b/library/alloctests/lib.rs index eca8444812521..3c26ecf9875e2 100644 --- a/library/alloctests/lib.rs +++ b/library/alloctests/lib.rs @@ -38,7 +38,6 @@ #![feature(maybe_uninit_uninit_array_transpose)] #![feature(ptr_alignment_type)] #![feature(ptr_cast_slice)] -#![feature(ptr_internals)] #![feature(rev_into_inner)] #![feature(sized_type_properties)] #![feature(slice_iter_mut_as_mut_slice)] diff --git a/src/etc/natvis/liballoc.natvis b/src/etc/natvis/liballoc.natvis index dade85dafe738..b56f6f5800eee 100644 --- a/src/etc/natvis/liballoc.natvis +++ b/src/etc/natvis/liballoc.natvis @@ -7,7 +7,7 @@ buf.inner.cap.__0 len - ($T1*)buf.inner.ptr.pointer.pointer + ($T1*)buf.inner.ptr.pointer @@ -23,7 +23,7 @@ - (($T1*)buf.inner.ptr.pointer.pointer)[(i + head.__0) % buf.inner.cap.__0] + (($T1*)buf.inner.ptr.pointer)[(i + head.__0) % buf.inner.cap.__0] i = i + 1 @@ -41,17 +41,17 @@ - {(char*)vec.buf.inner.ptr.pointer.pointer,[vec.len]s8} - (char*)vec.buf.inner.ptr.pointer.pointer,[vec.len]s8 + {(char*)vec.buf.inner.ptr.pointer,[vec.len]s8} + (char*)vec.buf.inner.ptr.pointer,[vec.len]s8 vec.len vec.buf.inner.cap.__0 - {(char*)vec.buf.inner.ptr.pointer.pointer,[vec.len]s8} + {(char*)vec.buf.inner.ptr.pointer,[vec.len]s8} vec.len - (char*)vec.buf.inner.ptr.pointer.pointer + (char*)vec.buf.inner.ptr.pointer diff --git a/src/etc/natvis/libstd.natvis b/src/etc/natvis/libstd.natvis index 93e94e5f38261..bfad30db3cf7a 100644 --- a/src/etc/natvis/libstd.natvis +++ b/src/etc/natvis/libstd.natvis @@ -104,14 +104,14 @@ - {(char*)inner.inner.bytes.buf.inner.ptr.pointer.pointer,[inner.inner.bytes.len]} + {(char*)inner.inner.bytes.buf.inner.ptr.pointer,[inner.inner.bytes.len]} - {(char*)inner.inner.bytes.buf.inner.ptr.pointer.pointer,[inner.inner.bytes.len]} + {(char*)inner.inner.bytes.buf.inner.ptr.pointer,[inner.inner.bytes.len]} inner.inner.bytes.len - (char*)inner.inner.bytes.buf.inner.ptr.pointer.pointer + (char*)inner.inner.bytes.buf.inner.ptr.pointer diff --git a/tests/debuginfo/strings-and-strs.rs b/tests/debuginfo/strings-and-strs.rs index 692c75bbfbc9d..4ad61e29d3ec0 100644 --- a/tests/debuginfo/strings-and-strs.rs +++ b/tests/debuginfo/strings-and-strs.rs @@ -8,7 +8,7 @@ //@ gdb-command:run //@ gdb-command:print plain_string -//@ gdb-check:$1 = alloc::string::String {vec: alloc::vec::Vec {buf: alloc::raw_vec::RawVec {inner: alloc::raw_vec::RawVecInner {ptr: core::ptr::unique::Unique {pointer: core::ptr::non_null::NonNull {pointer: 0x[...]}, _marker: core::marker::PhantomData}, cap: core::num::niche_types::UsizeNoHighBit (5), alloc: alloc::alloc::Global}, _marker: core::marker::PhantomData}, len: 5}} +//@ gdb-check:$1 = alloc::string::String {vec: alloc::vec::Vec {buf: alloc::raw_vec::RawVec {inner: alloc::raw_vec::RawVecInner {ptr: core::ptr::non_null::NonNull {pointer: 0x[...]}, cap: core::num::niche_types::UsizeNoHighBit (5), alloc: alloc::alloc::Global}, _marker: core::marker::PhantomData}, len: 5}} //@ gdb-command:print plain_str //@ gdb-check:$2 = "Hello" diff --git a/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff index 8b303fe1c87d9..a7cf6a7733083 100644 --- a/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff @@ -22,30 +22,26 @@ + scope 6 (inlined alloc::raw_vec::RawVecInner::ptr::) { + scope 7 (inlined alloc::raw_vec::RawVecInner::non_null::) { + let mut _12: std::ptr::NonNull; -+ scope 8 (inlined std::ptr::Unique::::cast::) { -+ scope 9 (inlined NonNull::::cast::) { -+ scope 10 (inlined NonNull::::as_ptr) { -+ } ++ scope 8 (inlined NonNull::::cast::) { ++ scope 9 (inlined NonNull::::as_ptr) { + } + } -+ scope 11 (inlined std::ptr::Unique::::as_non_null_ptr) { -+ } + } -+ scope 12 (inlined NonNull::::as_ptr) { ++ scope 10 (inlined NonNull::::as_ptr) { + } + } + } + } -+ scope 13 (inlined std::ptr::mut_ptr::::cast_slice) { -+ scope 14 (inlined slice_from_raw_parts_mut::) { -+ scope 15 (inlined std::ptr::from_raw_parts_mut::<[A], A>) { ++ scope 11 (inlined std::ptr::mut_ptr::::cast_slice) { ++ scope 12 (inlined slice_from_raw_parts_mut::) { ++ scope 13 (inlined std::ptr::from_raw_parts_mut::<[A], A>) { + } + } + } -+ scope 16 (inlined std::ptr::mut_ptr::::drop_in_place) { -+ scope 17 (inlined drop_in_place::<[A]>) { ++ scope 14 (inlined std::ptr::mut_ptr::::drop_in_place) { ++ scope 15 (inlined drop_in_place::<[A]>) { + let mut _13: &mut [A]; -+ scope 18 (inlined std::ptr::drop_glue::<[A]> - shim(Some([A]))) { ++ scope 16 (inlined std::ptr::drop_glue::<[A]> - shim(Some([A]))) { + let mut _14: usize; + let mut _15: *mut A; + let mut _16: bool; @@ -55,9 +51,9 @@ + } + } + } -+ scope 19 (inlined drop_in_place::>) { ++ scope 17 (inlined drop_in_place::>) { + let mut _17: &mut std::option::Option; -+ scope 20 (inlined std::ptr::drop_glue::> - shim(Some(Option))) { ++ scope 18 (inlined std::ptr::drop_glue::> - shim(Some(Option))) { + let mut _18: isize; + let mut _19: isize; + } @@ -77,7 +73,7 @@ + StorageLive(_9); + StorageLive(_10); + StorageLive(_12); -+ _12 = copy (((((*_7).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique).0: std::ptr::NonNull); ++ _12 = copy ((((*_7).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::NonNull); + _10 = copy _12 as *mut A (Transmute); + StorageDead(_12); + _11 = copy ((*_7).1: usize); diff --git a/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-abort.diff index 6bf6ede926004..fb406b8dfefc9 100644 --- a/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-abort.diff @@ -57,57 +57,53 @@ scope 11 (inlined alloc::raw_vec::RawVecInner::ptr::) { scope 12 (inlined alloc::raw_vec::RawVecInner::non_null::) { let mut _34: std::ptr::NonNull; - scope 13 (inlined std::ptr::Unique::::cast::) { - scope 14 (inlined NonNull::::cast::) { - scope 15 (inlined NonNull::::as_ptr) { - } + scope 13 (inlined NonNull::::cast::) { + scope 14 (inlined NonNull::::as_ptr) { } } - scope 16 (inlined std::ptr::Unique::::as_non_null_ptr) { - } } - scope 17 (inlined NonNull::::as_ptr) { + scope 15 (inlined NonNull::::as_ptr) { } } } } } - scope 18 (inlined from_utf8_unchecked) { + scope 16 (inlined from_utf8_unchecked) { } } - scope 19 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { + scope 17 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { } } - scope 20 (inlined #[track_caller] core::str::traits:: for str>::index) { - scope 21 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { + scope 18 (inlined #[track_caller] core::str::traits:: for str>::index) { + scope 19 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { } } - scope 22 (inlined core::str::traits::::eq) { + scope 20 (inlined core::str::traits::::eq) { let mut _35: &&[u8]; let _36: &[u8]; let mut _37: &&[u8]; let _38: &[u8]; - scope 23 (inlined core::str::::as_bytes) { + scope 21 (inlined core::str::::as_bytes) { } - scope 24 (inlined core::str::::as_bytes) { + scope 22 (inlined core::str::::as_bytes) { } - scope 25 (inlined std::cmp::impls::::eq) { - scope 26 (inlined core::slice::cmp::::eq) { + scope 23 (inlined std::cmp::impls::::eq) { + scope 24 (inlined core::slice::cmp::::eq) { let _39: usize; let mut _40: bool; let mut _41: usize; let mut _42: *const u8; let mut _43: *const u8; - scope 27 { - scope 28 (inlined core::slice::::as_ptr) { + scope 25 { + scope 26 (inlined core::slice::::as_ptr) { let mut _44: *const [u8]; } - scope 29 (inlined core::slice::::as_ptr) { + scope 27 (inlined core::slice::::as_ptr) { let mut _45: *const [u8]; } - scope 30 (inlined >::equal_same_length) { + scope 28 (inlined >::equal_same_length) { let mut _46: i32; - scope 31 { + scope 29 { } } } @@ -116,74 +112,70 @@ } } } - scope 32 (inlined std::cmp::impls:: for &String>::eq) { + scope 30 (inlined std::cmp::impls:: for &String>::eq) { let mut _47: &std::string::String; let mut _48: &str; - scope 33 (inlined >::eq) { - scope 34 (inlined #[track_caller] >::index) { + scope 31 (inlined >::eq) { + scope 32 (inlined #[track_caller] >::index) { let _49: &str; - scope 35 (inlined String::as_str) { + scope 33 (inlined String::as_str) { let _50: &[u8]; - scope 36 (inlined Vec::::as_slice) { + scope 34 (inlined Vec::::as_slice) { let _51: *const [u8]; let mut _52: *const u8; let mut _53: usize; - scope 37 (inlined Vec::::as_ptr) { - scope 38 (inlined alloc::raw_vec::RawVec::::ptr) { - scope 39 (inlined alloc::raw_vec::RawVecInner::ptr::) { - scope 40 (inlined alloc::raw_vec::RawVecInner::non_null::) { + scope 35 (inlined Vec::::as_ptr) { + scope 36 (inlined alloc::raw_vec::RawVec::::ptr) { + scope 37 (inlined alloc::raw_vec::RawVecInner::ptr::) { + scope 38 (inlined alloc::raw_vec::RawVecInner::non_null::) { let mut _54: std::ptr::NonNull; - scope 41 (inlined std::ptr::Unique::::cast::) { - scope 42 (inlined NonNull::::cast::) { - scope 43 (inlined NonNull::::as_ptr) { - } + scope 39 (inlined NonNull::::cast::) { + scope 40 (inlined NonNull::::as_ptr) { } } - scope 44 (inlined std::ptr::Unique::::as_non_null_ptr) { - } } - scope 45 (inlined NonNull::::as_ptr) { + scope 41 (inlined NonNull::::as_ptr) { } } } } } - scope 46 (inlined from_utf8_unchecked) { + scope 42 (inlined from_utf8_unchecked) { } } - scope 47 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { + scope 43 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { } } - scope 48 (inlined #[track_caller] core::str::traits:: for str>::index) { - scope 49 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { + scope 44 (inlined #[track_caller] core::str::traits:: for str>::index) { + scope 45 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { } } - scope 50 (inlined core::str::traits::::eq) { + scope 46 (inlined core::str::traits::::eq) { let mut _55: &&[u8]; let _56: &[u8]; let mut _57: &&[u8]; let _58: &[u8]; - scope 51 (inlined core::str::::as_bytes) { + scope 47 (inlined core::str::::as_bytes) { } - scope 52 (inlined core::str::::as_bytes) { + scope 48 (inlined core::str::::as_bytes) { } - scope 53 (inlined std::cmp::impls::::eq) { - scope 54 (inlined core::slice::cmp::::eq) { + scope 49 (inlined std::cmp::impls::::eq) { + scope 50 (inlined core::slice::cmp::::eq) { let _59: usize; let mut _60: bool; let mut _61: usize; let mut _62: *const u8; let mut _63: *const u8; - scope 55 { - scope 56 (inlined core::slice::::as_ptr) { + scope 51 { + scope 52 (inlined core::slice::::as_ptr) { let mut _64: *const [u8]; } - scope 57 (inlined core::slice::::as_ptr) { + scope 53 (inlined core::slice::::as_ptr) { let mut _65: *const [u8]; } - scope 58 (inlined >::equal_same_length) { + scope 54 (inlined >::equal_same_length) { let mut _66: i32; - scope 59 { + scope 55 { } } } @@ -238,7 +230,7 @@ StorageLive(_31); StorageLive(_32); StorageLive(_34); - _34 = copy ((((((*_27).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique).0: std::ptr::NonNull); + _34 = copy (((((*_27).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::NonNull); _32 = copy _34 as *const u8 (Transmute); StorageDead(_34); StorageLive(_33); @@ -300,7 +292,7 @@ StorageLive(_51); StorageLive(_52); StorageLive(_54); - _54 = copy ((((((*_47).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique).0: std::ptr::NonNull); + _54 = copy (((((*_47).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::NonNull); _52 = copy _54 as *const u8 (Transmute); StorageDead(_54); StorageLive(_53); diff --git a/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-unwind.diff index 8e52a92f5d0d7..d291e3d1eb51e 100644 --- a/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.chained_conditions.JumpThreading.panic-unwind.diff @@ -57,57 +57,53 @@ scope 11 (inlined alloc::raw_vec::RawVecInner::ptr::) { scope 12 (inlined alloc::raw_vec::RawVecInner::non_null::) { let mut _34: std::ptr::NonNull; - scope 13 (inlined std::ptr::Unique::::cast::) { - scope 14 (inlined NonNull::::cast::) { - scope 15 (inlined NonNull::::as_ptr) { - } + scope 13 (inlined NonNull::::cast::) { + scope 14 (inlined NonNull::::as_ptr) { } } - scope 16 (inlined std::ptr::Unique::::as_non_null_ptr) { - } } - scope 17 (inlined NonNull::::as_ptr) { + scope 15 (inlined NonNull::::as_ptr) { } } } } } - scope 18 (inlined from_utf8_unchecked) { + scope 16 (inlined from_utf8_unchecked) { } } - scope 19 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { + scope 17 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { } } - scope 20 (inlined #[track_caller] core::str::traits:: for str>::index) { - scope 21 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { + scope 18 (inlined #[track_caller] core::str::traits:: for str>::index) { + scope 19 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { } } - scope 22 (inlined core::str::traits::::eq) { + scope 20 (inlined core::str::traits::::eq) { let mut _35: &&[u8]; let _36: &[u8]; let mut _37: &&[u8]; let _38: &[u8]; - scope 23 (inlined core::str::::as_bytes) { + scope 21 (inlined core::str::::as_bytes) { } - scope 24 (inlined core::str::::as_bytes) { + scope 22 (inlined core::str::::as_bytes) { } - scope 25 (inlined std::cmp::impls::::eq) { - scope 26 (inlined core::slice::cmp::::eq) { + scope 23 (inlined std::cmp::impls::::eq) { + scope 24 (inlined core::slice::cmp::::eq) { let _39: usize; let mut _40: bool; let mut _41: usize; let mut _42: *const u8; let mut _43: *const u8; - scope 27 { - scope 28 (inlined core::slice::::as_ptr) { + scope 25 { + scope 26 (inlined core::slice::::as_ptr) { let mut _44: *const [u8]; } - scope 29 (inlined core::slice::::as_ptr) { + scope 27 (inlined core::slice::::as_ptr) { let mut _45: *const [u8]; } - scope 30 (inlined >::equal_same_length) { + scope 28 (inlined >::equal_same_length) { let mut _46: i32; - scope 31 { + scope 29 { } } } @@ -116,74 +112,70 @@ } } } - scope 32 (inlined std::cmp::impls:: for &String>::eq) { + scope 30 (inlined std::cmp::impls:: for &String>::eq) { let mut _47: &std::string::String; let mut _48: &str; - scope 33 (inlined >::eq) { - scope 34 (inlined #[track_caller] >::index) { + scope 31 (inlined >::eq) { + scope 32 (inlined #[track_caller] >::index) { let _49: &str; - scope 35 (inlined String::as_str) { + scope 33 (inlined String::as_str) { let _50: &[u8]; - scope 36 (inlined Vec::::as_slice) { + scope 34 (inlined Vec::::as_slice) { let _51: *const [u8]; let mut _52: *const u8; let mut _53: usize; - scope 37 (inlined Vec::::as_ptr) { - scope 38 (inlined alloc::raw_vec::RawVec::::ptr) { - scope 39 (inlined alloc::raw_vec::RawVecInner::ptr::) { - scope 40 (inlined alloc::raw_vec::RawVecInner::non_null::) { + scope 35 (inlined Vec::::as_ptr) { + scope 36 (inlined alloc::raw_vec::RawVec::::ptr) { + scope 37 (inlined alloc::raw_vec::RawVecInner::ptr::) { + scope 38 (inlined alloc::raw_vec::RawVecInner::non_null::) { let mut _54: std::ptr::NonNull; - scope 41 (inlined std::ptr::Unique::::cast::) { - scope 42 (inlined NonNull::::cast::) { - scope 43 (inlined NonNull::::as_ptr) { - } + scope 39 (inlined NonNull::::cast::) { + scope 40 (inlined NonNull::::as_ptr) { } } - scope 44 (inlined std::ptr::Unique::::as_non_null_ptr) { - } } - scope 45 (inlined NonNull::::as_ptr) { + scope 41 (inlined NonNull::::as_ptr) { } } } } } - scope 46 (inlined from_utf8_unchecked) { + scope 42 (inlined from_utf8_unchecked) { } } - scope 47 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { + scope 43 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { } } - scope 48 (inlined #[track_caller] core::str::traits:: for str>::index) { - scope 49 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { + scope 44 (inlined #[track_caller] core::str::traits:: for str>::index) { + scope 45 (inlined #[track_caller] core::str::traits:: for RangeFull>::index) { } } - scope 50 (inlined core::str::traits::::eq) { + scope 46 (inlined core::str::traits::::eq) { let mut _55: &&[u8]; let _56: &[u8]; let mut _57: &&[u8]; let _58: &[u8]; - scope 51 (inlined core::str::::as_bytes) { + scope 47 (inlined core::str::::as_bytes) { } - scope 52 (inlined core::str::::as_bytes) { + scope 48 (inlined core::str::::as_bytes) { } - scope 53 (inlined std::cmp::impls::::eq) { - scope 54 (inlined core::slice::cmp::::eq) { + scope 49 (inlined std::cmp::impls::::eq) { + scope 50 (inlined core::slice::cmp::::eq) { let _59: usize; let mut _60: bool; let mut _61: usize; let mut _62: *const u8; let mut _63: *const u8; - scope 55 { - scope 56 (inlined core::slice::::as_ptr) { + scope 51 { + scope 52 (inlined core::slice::::as_ptr) { let mut _64: *const [u8]; } - scope 57 (inlined core::slice::::as_ptr) { + scope 53 (inlined core::slice::::as_ptr) { let mut _65: *const [u8]; } - scope 58 (inlined >::equal_same_length) { + scope 54 (inlined >::equal_same_length) { let mut _66: i32; - scope 59 { + scope 55 { } } } @@ -238,7 +230,7 @@ StorageLive(_31); StorageLive(_32); StorageLive(_34); - _34 = copy ((((((*_27).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique).0: std::ptr::NonNull); + _34 = copy (((((*_27).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::NonNull); _32 = copy _34 as *const u8 (Transmute); StorageDead(_34); StorageLive(_33); @@ -300,7 +292,7 @@ StorageLive(_51); StorageLive(_52); StorageLive(_54); - _54 = copy ((((((*_47).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique).0: std::ptr::NonNull); + _54 = copy (((((*_47).0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::NonNull); _52 = copy _54 as *const u8 (Transmute); StorageDead(_54); StorageLive(_53); diff --git a/tests/mir-opt/pre-codegen/loops.vec_move.runtime-optimized.after.mir b/tests/mir-opt/pre-codegen/loops.vec_move.runtime-optimized.after.mir index cad38c437e3c3..6815c22fc9552 100644 --- a/tests/mir-opt/pre-codegen/loops.vec_move.runtime-optimized.after.mir +++ b/tests/mir-opt/pre-codegen/loops.vec_move.runtime-optimized.after.mir @@ -50,78 +50,78 @@ fn vec_move(_1: Vec) -> () { scope 9 { debug cap => _19; } - scope 39 (inlined > as Deref>::deref) { + scope 37 (inlined > as Deref>::deref) { debug self => _37; } - scope 40 (inlined alloc::raw_vec::RawVec::::capacity) { + scope 38 (inlined alloc::raw_vec::RawVec::::capacity) { debug self => _36; let mut _38: &alloc::raw_vec::RawVecInner; - scope 41 (inlined std::mem::size_of::) { + scope 39 (inlined std::mem::size_of::) { } - scope 42 (inlined alloc::raw_vec::RawVecInner::capacity) { + scope 40 (inlined alloc::raw_vec::RawVecInner::capacity) { debug self => _38; debug elem_size => const ::SIZE; let mut _20: core::num::niche_types::UsizeNoHighBit; - scope 43 (inlined core::num::niche_types::UsizeNoHighBit::as_inner) { + scope 41 (inlined core::num::niche_types::UsizeNoHighBit::as_inner) { debug self => _20; } } } } - scope 25 (inlined > as Deref>::deref) { + scope 23 (inlined > as Deref>::deref) { debug self => _33; } - scope 26 (inlined Vec::::len) { + scope 24 (inlined Vec::::len) { debug self => _32; let mut _12: bool; - scope 27 { + scope 25 { } } - scope 28 (inlined std::ptr::mut_ptr::::wrapping_byte_add) { + scope 26 (inlined std::ptr::mut_ptr::::wrapping_byte_add) { debug self => _6; debug count => _11; let mut _13: *mut u8; let mut _17: *mut u8; let mut _18: *const impl Sized; - scope 29 (inlined std::ptr::mut_ptr::::cast::) { + scope 27 (inlined std::ptr::mut_ptr::::cast::) { debug self => _6; } - scope 30 (inlined std::ptr::mut_ptr::::wrapping_add) { + scope 28 (inlined std::ptr::mut_ptr::::wrapping_add) { debug self => _13; debug count => _11; let mut _14: isize; - scope 31 (inlined std::ptr::mut_ptr::::wrapping_offset) { + scope 29 (inlined std::ptr::mut_ptr::::wrapping_offset) { debug self => _13; debug count => _14; let mut _15: *const u8; let mut _16: *const u8; } } - scope 32 (inlined std::ptr::mut_ptr::::with_metadata_of::) { + scope 30 (inlined std::ptr::mut_ptr::::with_metadata_of::) { debug self => _17; debug meta => _18; - scope 33 (inlined std::ptr::metadata::) { + scope 31 (inlined std::ptr::metadata::) { debug ptr => _18; } - scope 34 (inlined std::ptr::from_raw_parts_mut::) { + scope 32 (inlined std::ptr::from_raw_parts_mut::) { } } } - scope 35 (inlined > as Deref>::deref) { + scope 33 (inlined > as Deref>::deref) { debug self => _35; } - scope 36 (inlined Vec::::len) { + scope 34 (inlined Vec::::len) { debug self => _34; let mut _8: bool; - scope 37 { + scope 35 { } } - scope 38 (inlined #[track_caller] std::ptr::mut_ptr::::add) { + scope 36 (inlined #[track_caller] std::ptr::mut_ptr::::add) { debug self => _6; debug count => _7; } } - scope 24 (inlined NonNull::::as_ptr) { + scope 22 (inlined NonNull::::as_ptr) { debug self => _5; } } @@ -132,14 +132,10 @@ fn vec_move(_1: Vec) -> () { debug self => _30; scope 19 (inlined alloc::raw_vec::RawVecInner::non_null::) { let mut _4: std::ptr::NonNull; - scope 20 (inlined std::ptr::Unique::::cast::) { - scope 21 (inlined NonNull::::cast::) { - scope 22 (inlined NonNull::::as_ptr) { - } + scope 20 (inlined NonNull::::cast::) { + scope 21 (inlined NonNull::::as_ptr) { } } - scope 23 (inlined std::ptr::Unique::::as_non_null_ptr) { - } } } } @@ -181,7 +177,7 @@ fn vec_move(_1: Vec) -> () { StorageLive(_5); // DBG: _31 = &_2; // DBG: _30 = &((_2.0: std::vec::Vec).0: alloc::raw_vec::RawVec); - _4 = copy (((((_2.0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique).0: std::ptr::NonNull); + _4 = copy ((((_2.0: std::vec::Vec).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::NonNull); _5 = copy _4 as std::ptr::NonNull (Transmute); StorageLive(_6); _6 = copy _4 as *mut impl Sized (Transmute); diff --git a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.runtime-optimized.after.panic-abort.mir b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.runtime-optimized.after.panic-abort.mir index 831a7d2a7b974..2c86c830c0e5f 100644 --- a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.runtime-optimized.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.runtime-optimized.after.panic-abort.mir @@ -16,16 +16,12 @@ fn vec_deref_to_slice(_1: &Vec) -> &[u8] { scope 5 (inlined alloc::raw_vec::RawVecInner::ptr::) { scope 6 (inlined alloc::raw_vec::RawVecInner::non_null::) { let mut _2: std::ptr::NonNull; - scope 7 (inlined std::ptr::Unique::::cast::) { - scope 8 (inlined NonNull::::cast::) { - scope 9 (inlined NonNull::::as_ptr) { - } + scope 7 (inlined NonNull::::cast::) { + scope 8 (inlined NonNull::::as_ptr) { } } - scope 10 (inlined std::ptr::Unique::::as_non_null_ptr) { - } } - scope 11 (inlined NonNull::::as_ptr) { + scope 9 (inlined NonNull::::as_ptr) { } } } @@ -37,7 +33,7 @@ fn vec_deref_to_slice(_1: &Vec) -> &[u8] { StorageLive(_5); StorageLive(_3); StorageLive(_2); - _2 = copy (((((*_1).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique).0: std::ptr::NonNull); + _2 = copy ((((*_1).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::NonNull); _3 = copy _2 as *const u8 (Transmute); StorageDead(_2); StorageLive(_4); diff --git a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.runtime-optimized.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.runtime-optimized.after.panic-unwind.mir index 831a7d2a7b974..2c86c830c0e5f 100644 --- a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.runtime-optimized.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.runtime-optimized.after.panic-unwind.mir @@ -16,16 +16,12 @@ fn vec_deref_to_slice(_1: &Vec) -> &[u8] { scope 5 (inlined alloc::raw_vec::RawVecInner::ptr::) { scope 6 (inlined alloc::raw_vec::RawVecInner::non_null::) { let mut _2: std::ptr::NonNull; - scope 7 (inlined std::ptr::Unique::::cast::) { - scope 8 (inlined NonNull::::cast::) { - scope 9 (inlined NonNull::::as_ptr) { - } + scope 7 (inlined NonNull::::cast::) { + scope 8 (inlined NonNull::::as_ptr) { } } - scope 10 (inlined std::ptr::Unique::::as_non_null_ptr) { - } } - scope 11 (inlined NonNull::::as_ptr) { + scope 9 (inlined NonNull::::as_ptr) { } } } @@ -37,7 +33,7 @@ fn vec_deref_to_slice(_1: &Vec) -> &[u8] { StorageLive(_5); StorageLive(_3); StorageLive(_2); - _2 = copy (((((*_1).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique).0: std::ptr::NonNull); + _2 = copy ((((*_1).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::NonNull); _3 = copy _2 as *const u8 (Transmute); StorageDead(_2); StorageLive(_4);