Skip to content

Commit

Permalink
Add allow for newly added unclear_fat_pointer_comparisons lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Nov 10, 2023
1 parent 5388007 commit d875d16
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions library/core/src/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1747,6 +1747,7 @@ impl<T> *const [T] {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> PartialEq for *const T {
#[inline]
#[allow(unclear_fat_pointer_comparisons)]
fn eq(&self, other: &*const T) -> bool {
*self == *other
}
Expand Down Expand Up @@ -1778,21 +1779,25 @@ impl<T: ?Sized> PartialOrd for *const T {
}

#[inline]
#[allow(unclear_fat_pointer_comparisons)]
fn lt(&self, other: &*const T) -> bool {
*self < *other
}

#[inline]
#[allow(unclear_fat_pointer_comparisons)]
fn le(&self, other: &*const T) -> bool {
*self <= *other
}

#[inline]
#[allow(unclear_fat_pointer_comparisons)]
fn gt(&self, other: &*const T) -> bool {
*self > *other
}

#[inline]
#[allow(unclear_fat_pointer_comparisons)]
fn ge(&self, other: &*const T) -> bool {
*self >= *other
}
Expand Down
1 change: 1 addition & 0 deletions library/core/src/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1885,6 +1885,7 @@ pub(crate) const unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usiz
#[inline(always)]
#[must_use = "pointer comparison produces a value"]
#[rustc_diagnostic_item = "ptr_eq"]
#[allow(unclear_fat_pointer_comparisons)] // it's actually clear here
pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
a == b
}
Expand Down
5 changes: 5 additions & 0 deletions library/core/src/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2189,6 +2189,7 @@ impl<T> *mut [T] {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> PartialEq for *mut T {
#[inline(always)]
#[allow(unclear_fat_pointer_comparisons)]
fn eq(&self, other: &*mut T) -> bool {
*self == *other
}
Expand Down Expand Up @@ -2219,21 +2220,25 @@ impl<T: ?Sized> PartialOrd for *mut T {
}

#[inline(always)]
#[allow(unclear_fat_pointer_comparisons)]
fn lt(&self, other: &*mut T) -> bool {
*self < *other
}

#[inline(always)]
#[allow(unclear_fat_pointer_comparisons)]
fn le(&self, other: &*mut T) -> bool {
*self <= *other
}

#[inline(always)]
#[allow(unclear_fat_pointer_comparisons)]
fn gt(&self, other: &*mut T) -> bool {
*self > *other
}

#[inline(always)]
#[allow(unclear_fat_pointer_comparisons)]
fn ge(&self, other: &*mut T) -> bool {
*self >= *other
}
Expand Down
1 change: 1 addition & 0 deletions library/core/src/ptr/non_null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ impl<T: ?Sized> Eq for NonNull<T> {}
#[stable(feature = "nonnull", since = "1.25.0")]
impl<T: ?Sized> PartialEq for NonNull<T> {
#[inline]
#[allow(unclear_fat_pointer_comparisons)]
fn eq(&self, other: &Self) -> bool {
self.as_ptr() == other.as_ptr()
}
Expand Down

0 comments on commit d875d16

Please sign in to comment.