Skip to content

Commit c490d47

Browse files
committed
Add detection of [Partial]Ord methods to the ambiguous wide ptr cmp lint
1 parent e838063 commit c490d47

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

core/src/ptr/const_ptr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,6 +1857,7 @@ impl<T: ?Sized> Ord for *const T {
18571857
#[stable(feature = "rust1", since = "1.0.0")]
18581858
impl<T: ?Sized> PartialOrd for *const T {
18591859
#[inline]
1860+
#[allow(ambiguous_wide_pointer_comparisons)]
18601861
fn partial_cmp(&self, other: &*const T) -> Option<Ordering> {
18611862
Some(self.cmp(other))
18621863
}

core/src/ptr/metadata.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ impl<Dyn: ?Sized> PartialEq for DynMetadata<Dyn> {
258258

259259
impl<Dyn: ?Sized> Ord for DynMetadata<Dyn> {
260260
#[inline]
261+
#[allow(ambiguous_wide_pointer_comparisons)]
261262
fn cmp(&self, other: &Self) -> crate::cmp::Ordering {
262263
(self.vtable_ptr as *const VTable).cmp(&(other.vtable_ptr as *const VTable))
263264
}

core/src/ptr/mut_ptr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,6 +2275,7 @@ impl<T: ?Sized> Ord for *mut T {
22752275
#[stable(feature = "rust1", since = "1.0.0")]
22762276
impl<T: ?Sized> PartialOrd for *mut T {
22772277
#[inline(always)]
2278+
#[allow(ambiguous_wide_pointer_comparisons)]
22782279
fn partial_cmp(&self, other: &*mut T) -> Option<Ordering> {
22792280
Some(self.cmp(other))
22802281
}

core/src/ptr/non_null.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,6 +1821,7 @@ impl<T: ?Sized> PartialEq for NonNull<T> {
18211821
#[stable(feature = "nonnull", since = "1.25.0")]
18221822
impl<T: ?Sized> Ord for NonNull<T> {
18231823
#[inline]
1824+
#[allow(ambiguous_wide_pointer_comparisons)]
18241825
fn cmp(&self, other: &Self) -> Ordering {
18251826
self.as_ptr().cmp(&other.as_ptr())
18261827
}
@@ -1829,6 +1830,7 @@ impl<T: ?Sized> Ord for NonNull<T> {
18291830
#[stable(feature = "nonnull", since = "1.25.0")]
18301831
impl<T: ?Sized> PartialOrd for NonNull<T> {
18311832
#[inline]
1833+
#[allow(ambiguous_wide_pointer_comparisons)]
18321834
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
18331835
self.as_ptr().partial_cmp(&other.as_ptr())
18341836
}

0 commit comments

Comments
 (0)