diff options
| author | bors <bors@rust-lang.org> | 2023-10-04 00:03:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-10-04 00:03:54 +0000 |
| commit | 79f38b79147a5fb3c52d1fd1afc571226a77419c (patch) | |
| tree | f5470bba7c28d1ed146c553663c1926212d5548c | |
| parent | 187b8131d4f760f856b214fce34534903276f2ef (diff) | |
| parent | f8fc0d771623875e6f9515c22aa58b4aedba839e (diff) | |
| download | rust-79f38b79147a5fb3c52d1fd1afc571226a77419c.tar.gz rust-79f38b79147a5fb3c52d1fd1afc571226a77419c.zip | |
Auto merge of #116367 - scottmcm:more-addr-eq, r=workingjubilee
Use `addr_eq` in `{Arc,Rc}::ptr_eq`
Since it's made for stuff like this (see #106447)
| -rw-r--r-- | library/alloc/src/lib.rs | 1 | ||||
| -rw-r--r-- | library/alloc/src/rc.rs | 4 | ||||
| -rw-r--r-- | library/alloc/src/sync.rs | 4 |
3 files changed, 5 insertions, 4 deletions
diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index f435f503fc1..cd3648214a4 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -140,6 +140,7 @@ #![feature(maybe_uninit_uninit_array_transpose)] #![feature(pattern)] #![feature(pointer_byte_offsets)] +#![feature(ptr_addr_eq)] #![feature(ptr_internals)] #![feature(ptr_metadata)] #![feature(ptr_sub_ptr)] diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 8dbaca223aa..124f16cfc62 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -1649,7 +1649,7 @@ impl<T: ?Sized, A: Allocator> Rc<T, A> { /// assert!(!Rc::ptr_eq(&five, &other_five)); /// ``` pub fn ptr_eq(this: &Self, other: &Self) -> bool { - this.ptr.as_ptr() as *const () == other.ptr.as_ptr() as *const () + ptr::addr_eq(this.ptr.as_ptr(), other.ptr.as_ptr()) } } @@ -3146,7 +3146,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> { #[must_use] #[stable(feature = "weak_ptr_eq", since = "1.39.0")] pub fn ptr_eq(&self, other: &Self) -> bool { - ptr::eq(self.ptr.as_ptr() as *const (), other.ptr.as_ptr() as *const ()) + ptr::addr_eq(self.ptr.as_ptr(), other.ptr.as_ptr()) } } diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 61f4bfc54b0..415825cc878 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -1778,7 +1778,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> { #[must_use] #[stable(feature = "ptr_eq", since = "1.17.0")] pub fn ptr_eq(this: &Self, other: &Self) -> bool { - this.ptr.as_ptr() as *const () == other.ptr.as_ptr() as *const () + ptr::addr_eq(this.ptr.as_ptr(), other.ptr.as_ptr()) } } @@ -2900,7 +2900,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> { #[must_use] #[stable(feature = "weak_ptr_eq", since = "1.39.0")] pub fn ptr_eq(&self, other: &Self) -> bool { - ptr::eq(self.ptr.as_ptr() as *const (), other.ptr.as_ptr() as *const ()) + ptr::addr_eq(self.ptr.as_ptr(), other.ptr.as_ptr()) } } |
