diff options
| author | bors <bors@rust-lang.org> | 2023-06-21 05:13:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-06-21 05:13:39 +0000 |
| commit | 67da586efe13aa66eef576ba095e1875ba65fd20 (patch) | |
| tree | 9083d473b8ae1502b194451ca59983301f2cc6dd /library/alloc/src | |
| parent | c55d1ee8d4e3162187214692229a63c2cc5e0f31 (diff) | |
| parent | f04da2218c5a88c77496744fa74c4616b41bf357 (diff) | |
| download | rust-67da586efe13aa66eef576ba095e1875ba65fd20.tar.gz rust-67da586efe13aa66eef576ba095e1875ba65fd20.zip | |
Auto merge of #106450 - albertlarsan68:fix-arc-ptr-eq, r=Amanieu
Make `{Arc,Rc,Weak}::ptr_eq` ignore pointer metadata
FCP completed in https://github.com/rust-lang/rust/issues/103763#issuecomment-1362267967
Closes #103763
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/rc.rs | 10 | ||||
| -rw-r--r-- | library/alloc/src/sync.rs | 10 |
2 files changed, 10 insertions, 10 deletions
diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 0f91bc8ed80..b3305b8ca6d 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -1169,7 +1169,7 @@ impl<T: ?Sized> Rc<T> { #[inline] #[stable(feature = "ptr_eq", since = "1.17.0")] /// Returns `true` if the two `Rc`s point to the same allocation in a vein similar to - /// [`ptr::eq`]. See [that function][`ptr::eq`] for caveats when comparing `dyn Trait` pointers. + /// [`ptr::eq`]. This function ignores the metadata of `dyn Trait` pointers. /// /// # Examples /// @@ -1184,7 +1184,7 @@ impl<T: ?Sized> Rc<T> { /// assert!(!Rc::ptr_eq(&five, &other_five)); /// ``` pub fn ptr_eq(this: &Self, other: &Self) -> bool { - this.ptr.as_ptr() == other.ptr.as_ptr() + this.ptr.as_ptr() as *const () == other.ptr.as_ptr() as *const () } } @@ -2466,8 +2466,8 @@ impl<T: ?Sized> Weak<T> { } /// Returns `true` if the two `Weak`s point to the same allocation similar to [`ptr::eq`], or if - /// both don't point to any allocation (because they were created with `Weak::new()`). See [that - /// function][`ptr::eq`] for caveats when comparing `dyn Trait` pointers. + /// both don't point to any allocation (because they were created with `Weak::new()`). However, + /// this function ignores the metadata of `dyn Trait` pointers. /// /// # Notes /// @@ -2508,7 +2508,7 @@ impl<T: ?Sized> Weak<T> { #[must_use] #[stable(feature = "weak_ptr_eq", since = "1.39.0")] pub fn ptr_eq(&self, other: &Self) -> bool { - self.ptr.as_ptr() == other.ptr.as_ptr() + ptr::eq(self.ptr.as_ptr() as *const (), other.ptr.as_ptr() as *const ()) } } diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index d2c87cf705c..5bb1a93aeaf 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -1267,7 +1267,7 @@ impl<T: ?Sized> Arc<T> { } /// Returns `true` if the two `Arc`s point to the same allocation in a vein similar to - /// [`ptr::eq`]. See [that function][`ptr::eq`] for caveats when comparing `dyn Trait` pointers. + /// [`ptr::eq`]. This function ignores the metadata of `dyn Trait` pointers. /// /// # Examples /// @@ -1287,7 +1287,7 @@ impl<T: ?Sized> Arc<T> { #[must_use] #[stable(feature = "ptr_eq", since = "1.17.0")] pub fn ptr_eq(this: &Self, other: &Self) -> bool { - this.ptr.as_ptr() == other.ptr.as_ptr() + this.ptr.as_ptr() as *const () == other.ptr.as_ptr() as *const () } } @@ -2254,8 +2254,8 @@ impl<T: ?Sized> Weak<T> { } /// Returns `true` if the two `Weak`s point to the same allocation similar to [`ptr::eq`], or if - /// both don't point to any allocation (because they were created with `Weak::new()`). See [that - /// function][`ptr::eq`] for caveats when comparing `dyn Trait` pointers. + /// both don't point to any allocation (because they were created with `Weak::new()`). However, + /// this function ignores the metadata of `dyn Trait` pointers. /// /// # Notes /// @@ -2298,7 +2298,7 @@ impl<T: ?Sized> Weak<T> { #[must_use] #[stable(feature = "weak_ptr_eq", since = "1.39.0")] pub fn ptr_eq(&self, other: &Self) -> bool { - self.ptr.as_ptr() == other.ptr.as_ptr() + ptr::eq(self.ptr.as_ptr() as *const (), other.ptr.as_ptr() as *const ()) } } |
