diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 1c5718473a06b..f4d1d6ff0986f 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -2431,8 +2431,6 @@ impl fmt::Debug for Box { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Pointer for Box { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - // It's not possible to extract the inner Uniq directly from the Box, - // instead we cast it to a *const which aliases the Unique let ptr: *const T = &**self; fmt::Pointer::fmt(&ptr, f) } diff --git a/library/core/src/panic/unwind_safe.rs b/library/core/src/panic/unwind_safe.rs index 79141ec4370d7..301336fda074c 100644 --- a/library/core/src/panic/unwind_safe.rs +++ b/library/core/src/panic/unwind_safe.rs @@ -174,7 +174,6 @@ pub struct AssertUnwindSafe(#[stable(feature = "catch_unwind", since = "1.9.0 // // * By default everything is unwind safe // * pointers T contains mutability of some form are not unwind safe -// * Unique, an owning pointer, lifts an implementation // * Types like Mutex/RwLock which are explicitly poisoned are unwind safe // * Our custom AssertUnwindSafe wrapper is indeed unwind safe diff --git a/src/etc/gdb_providers.py b/src/etc/gdb_providers.py index 9c50d7e472000..f04bace1ebcd9 100644 --- a/src/etc/gdb_providers.py +++ b/src/etc/gdb_providers.py @@ -9,12 +9,14 @@ FIRST_FIELD = "__1" -def unwrap_unique_or_non_null(unique_or_nonnull): +# Gets the raw pointer out of a `NonNull` or a wrapper struct with a +# `pointer: NonNull` field (with that exact name) +def unwrap_non_null_or_wrapper(ptr): # BACKCOMPAT: rust 1.32 # https://github.com/rust-lang/rust/commit/7a0911528058e87d22ea305695f4047572c5e067 # BACKCOMPAT: rust 1.60 # https://github.com/rust-lang/rust/commit/2a91eeac1a2d27dd3de1bf55515d765da20fd86f - ptr = unique_or_nonnull["pointer"] + ptr = ptr["pointer"] return ptr if ptr.type.code == gdb.TYPE_CODE_PTR else ptr[ptr.type.fields()[0]] @@ -62,7 +64,7 @@ def __init__(self, valobj): self._valobj = valobj vec = valobj["vec"] self._length = int(vec["len"]) - self._data_ptr = unwrap_unique_or_non_null(vec["buf"]["inner"]["ptr"]) + self._data_ptr = unwrap_non_null_or_wrapper(vec["buf"]["inner"]["ptr"]) def to_string(self): return self._data_ptr.lazy_string(encoding="utf-8", length=self._length) @@ -80,7 +82,7 @@ def __init__(self, valobj): vec = buf["bytes"] if is_windows else buf self._length = int(vec["len"]) - self._data_ptr = unwrap_unique_or_non_null(vec["buf"]["inner"]["ptr"]) + self._data_ptr = unwrap_non_null_or_wrapper(vec["buf"]["inner"]["ptr"]) def to_string(self): return self._data_ptr.lazy_string(encoding="utf-8", length=self._length) @@ -160,7 +162,7 @@ class StdVecProvider(printer_base): def __init__(self, valobj): self._valobj = valobj self._length = int(valobj["len"]) - self._data_ptr = unwrap_unique_or_non_null(valobj["buf"]["inner"]["ptr"]) + self._data_ptr = unwrap_non_null_or_wrapper(valobj["buf"]["inner"]["ptr"]) ptr_ty = gdb.Type.pointer(valobj.type.template_argument(0)) self._data_ptr = self._data_ptr.reinterpret_cast(ptr_ty) @@ -196,7 +198,7 @@ def __init__(self, valobj): if cap.type.code != gdb.TYPE_CODE_INT: cap = cap[ZERO_FIELD] self._cap = int(cap) - self._data_ptr = unwrap_unique_or_non_null(valobj["buf"]["inner"]["ptr"]) + self._data_ptr = unwrap_non_null_or_wrapper(valobj["buf"]["inner"]["ptr"]) ptr_ty = gdb.Type.pointer(valobj.type.template_argument(0)) self._data_ptr = self._data_ptr.reinterpret_cast(ptr_ty) @@ -221,7 +223,7 @@ class StdRcProvider(printer_base): def __init__(self, valobj, is_atomic=False): self._valobj = valobj self._is_atomic = is_atomic - self._ptr = unwrap_unique_or_non_null(valobj["ptr"]) + self._ptr = unwrap_non_null_or_wrapper(valobj["ptr"]) self._value = self._ptr["data" if is_atomic else "value"] # FIXME(shua): the debuginfo template type should be 'str' not 'u8' if self._ptr.type.target().name == "alloc::rc::RcInner": @@ -321,7 +323,7 @@ def cast_to_internal(node): if node_ptr.type.name.startswith("alloc::collections::btree::node::BoxedNode<"): # BACKCOMPAT: rust 1.49 node_ptr = node_ptr["ptr"] - node_ptr = unwrap_unique_or_non_null(node_ptr) + node_ptr = unwrap_non_null_or_wrapper(node_ptr) leaf = node_ptr.dereference() keys = leaf["keys"] vals = leaf["vals"] diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py index 10557e8cb351c..1bb4883db8de2 100644 --- a/src/etc/lldb_providers.py +++ b/src/etc/lldb_providers.py @@ -161,12 +161,14 @@ def from_uint(self, name: str, value: int) -> SBValue: return self.valobj.CreateValueFromData(name, data, type) -def unwrap_unique_or_non_null(unique_or_nonnull: SBValue) -> SBValue: +# Gets the raw pointer out of a `NonNull` or a wrapper struct with a +# `pointer: NonNull` field (with that exact name) +def unwrap_non_null_or_wrapper(ptr: SBValue) -> SBValue: # BACKCOMPAT: rust 1.32 # https://github.com/rust-lang/rust/commit/7a0911528058e87d22ea305695f4047572c5e067 # BACKCOMPAT: rust 1.60 # https://github.com/rust-lang/rust/commit/2a91eeac1a2d27dd3de1bf55515d765da20fd86f - ptr = unique_or_nonnull.GetChildMemberWithName("pointer") + ptr = ptr.GetChildMemberWithName("pointer") return ptr if ptr.TypeIsPointerType() else ptr.GetChildAtIndex(0) @@ -417,7 +419,7 @@ def StdStringSummaryProvider(valobj: SBValue, dict: LLDBOpaque): .GetNonSyntheticValue() ) - pointer = unwrap_unique_or_non_null( + pointer = unwrap_non_null_or_wrapper( inner_vec.GetChildMemberWithName("buf") .GetChildMemberWithName("inner") .GetChildMemberWithName("ptr") @@ -453,7 +455,7 @@ def StdOsStringSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str: if is_windows: inner_vec = inner_vec.GetChildAtIndex(0) - pointer = unwrap_unique_or_non_null( + pointer = unwrap_non_null_or_wrapper( inner_vec.GetChildMemberWithName("buf") .GetChildMemberWithName("inner") .GetChildMemberWithName("ptr") @@ -614,7 +616,7 @@ def __init__(self, valobj: SBValue, _dict: LLDBOpaque): def update(self): inner_vec = self.valobj.GetChildMemberWithName("vec").GetNonSyntheticValue() - self.data_ptr = unwrap_unique_or_non_null( + self.data_ptr = unwrap_non_null_or_wrapper( inner_vec.GetChildMemberWithName("buf") .GetChildMemberWithName("inner") .GetChildMemberWithName("ptr") @@ -1158,7 +1160,7 @@ def get_child_at_index(self, index: int) -> Optional[SBValue]: def update(self): buf: SBValue = self.valobj.GetChildMemberWithName("buf") - self.data_ptr = unwrap_unique_or_non_null( + self.data_ptr = unwrap_non_null_or_wrapper( buf.GetChildMemberWithName("inner").GetChildMemberWithName("ptr") ) @@ -1333,7 +1335,7 @@ def update(self): cap = cap.GetChildAtIndex(0) self.cap = cap.GetValueAsUnsigned() - self.data_ptr = unwrap_unique_or_non_null( + self.data_ptr = unwrap_non_null_or_wrapper( self.buf.GetChildMemberWithName("ptr") ) @@ -1569,7 +1571,7 @@ class StdRcSyntheticProvider: def __init__(self, valobj: SBValue, _dict: LLDBOpaque, is_atomic: bool = False): self.valobj = valobj - self.ptr = unwrap_unique_or_non_null(self.valobj.GetChildMemberWithName("ptr")) + self.ptr = unwrap_non_null_or_wrapper(self.valobj.GetChildMemberWithName("ptr")) self.value = self.ptr.GetChildMemberWithName("data" if is_atomic else "value") diff --git a/src/etc/natvis/libcore.natvis b/src/etc/natvis/libcore.natvis index 20ce1cae447cf..23c061e2ab8d0 100644 --- a/src/etc/natvis/libcore.natvis +++ b/src/etc/natvis/libcore.natvis @@ -82,13 +82,6 @@ - - Unique({(void*)pointer.pointer}: {pointer.pointer}) - - pointer - - - {(bool)v.value.__0} diff --git a/tests/ui/functions-closures/nullable-pointer-opt-closures.rs b/tests/ui/functions-closures/nullable-pointer-opt-closures.rs index 2cafe1b7aba8a..343e92a5c269b 100644 --- a/tests/ui/functions-closures/nullable-pointer-opt-closures.rs +++ b/tests/ui/functions-closures/nullable-pointer-opt-closures.rs @@ -19,10 +19,10 @@ pub fn main() { assert_eq!(mem::size_of_val(&b), mem::size_of::>()); // By Value Capture - Transitive case - let a = "Hello".to_string(); // String -> Vec -> Unique -> NonZero + let a = "Hello".to_string(); // String -> Vec -> NonNull let b = Some(move || println!("{}", a)); // We captured `a` by value and since down the chain it contains - // a `NonZero` field, we can use it as the discriminant. + // a `NonNull` field, we can use it as the discriminant. assert_eq!(mem::size_of_val(&b), mem::size_of::()); // By Value - No Optimization diff --git a/tests/ui/print_type_sizes/niche-filling.rs b/tests/ui/print_type_sizes/niche-filling.rs index 1bcbdf2a999c1..2fcb1dfe3c8c2 100644 --- a/tests/ui/print_type_sizes/niche-filling.rs +++ b/tests/ui/print_type_sizes/niche-filling.rs @@ -1,7 +1,7 @@ //! This file illustrates how niche-filling enums are handled, //! modelled after cases like `Option<&u32>`, `Option` and such. //! -//! It uses `NonZero` rather than `&_` or `Unique<_>`, because +//! It uses `NonZero` rather than `&_` or `NonNull<_>`, because //! the test is not set up to deal with target-dependent pointer width. //! //! It avoids using `u64`/`i64` because on some targets that is only 4-byte