Skip to content

Commit 30c7b18

Browse files
committed
Allow ambiguous_wide_pointer_comparisons lint for std methods
1 parent 6856a86 commit 30c7b18

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

library/core/src/ptr/const_ptr.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,7 @@ impl<T> *const [T] {
17651765
#[stable(feature = "rust1", since = "1.0.0")]
17661766
impl<T: ?Sized> PartialEq for *const T {
17671767
#[inline]
1768+
#[cfg_attr(not(bootstrap), allow(ambiguous_wide_pointer_comparisons))]
17681769
fn eq(&self, other: &*const T) -> bool {
17691770
*self == *other
17701771
}
@@ -1777,6 +1778,7 @@ impl<T: ?Sized> Eq for *const T {}
17771778
#[stable(feature = "rust1", since = "1.0.0")]
17781779
impl<T: ?Sized> Ord for *const T {
17791780
#[inline]
1781+
#[cfg_attr(not(bootstrap), allow(ambiguous_wide_pointer_comparisons))]
17801782
fn cmp(&self, other: &*const T) -> Ordering {
17811783
if self < other {
17821784
Less
@@ -1796,21 +1798,25 @@ impl<T: ?Sized> PartialOrd for *const T {
17961798
}
17971799

17981800
#[inline]
1801+
#[cfg_attr(not(bootstrap), allow(ambiguous_wide_pointer_comparisons))]
17991802
fn lt(&self, other: &*const T) -> bool {
18001803
*self < *other
18011804
}
18021805

18031806
#[inline]
1807+
#[cfg_attr(not(bootstrap), allow(ambiguous_wide_pointer_comparisons))]
18041808
fn le(&self, other: &*const T) -> bool {
18051809
*self <= *other
18061810
}
18071811

18081812
#[inline]
1813+
#[cfg_attr(not(bootstrap), allow(ambiguous_wide_pointer_comparisons))]
18091814
fn gt(&self, other: &*const T) -> bool {
18101815
*self > *other
18111816
}
18121817

18131818
#[inline]
1819+
#[cfg_attr(not(bootstrap), allow(ambiguous_wide_pointer_comparisons))]
18141820
fn ge(&self, other: &*const T) -> bool {
18151821
*self >= *other
18161822
}

library/core/src/ptr/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1885,6 +1885,7 @@ pub(crate) const unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usiz
18851885
#[inline(always)]
18861886
#[must_use = "pointer comparison produces a value"]
18871887
#[rustc_diagnostic_item = "ptr_eq"]
1888+
#[cfg_attr(not(bootstrap), allow(ambiguous_wide_pointer_comparisons))] // it's actually clear here
18881889
pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
18891890
a == b
18901891
}

library/core/src/ptr/mut_ptr.rs

+6
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,7 @@ impl<T> *mut [T] {
21892189
#[stable(feature = "rust1", since = "1.0.0")]
21902190
impl<T: ?Sized> PartialEq for *mut T {
21912191
#[inline(always)]
2192+
#[cfg_attr(not(bootstrap), allow(ambiguous_wide_pointer_comparisons))]
21922193
fn eq(&self, other: &*mut T) -> bool {
21932194
*self == *other
21942195
}
@@ -2200,6 +2201,7 @@ impl<T: ?Sized> Eq for *mut T {}
22002201
#[stable(feature = "rust1", since = "1.0.0")]
22012202
impl<T: ?Sized> Ord for *mut T {
22022203
#[inline]
2204+
#[cfg_attr(not(bootstrap), allow(ambiguous_wide_pointer_comparisons))]
22032205
fn cmp(&self, other: &*mut T) -> Ordering {
22042206
if self < other {
22052207
Less
@@ -2219,21 +2221,25 @@ impl<T: ?Sized> PartialOrd for *mut T {
22192221
}
22202222

22212223
#[inline(always)]
2224+
#[cfg_attr(not(bootstrap), allow(ambiguous_wide_pointer_comparisons))]
22222225
fn lt(&self, other: &*mut T) -> bool {
22232226
*self < *other
22242227
}
22252228

22262229
#[inline(always)]
2230+
#[cfg_attr(not(bootstrap), allow(ambiguous_wide_pointer_comparisons))]
22272231
fn le(&self, other: &*mut T) -> bool {
22282232
*self <= *other
22292233
}
22302234

22312235
#[inline(always)]
2236+
#[cfg_attr(not(bootstrap), allow(ambiguous_wide_pointer_comparisons))]
22322237
fn gt(&self, other: &*mut T) -> bool {
22332238
*self > *other
22342239
}
22352240

22362241
#[inline(always)]
2242+
#[cfg_attr(not(bootstrap), allow(ambiguous_wide_pointer_comparisons))]
22372243
fn ge(&self, other: &*mut T) -> bool {
22382244
*self >= *other
22392245
}

library/core/src/ptr/non_null.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1792,6 +1792,7 @@ impl<T: ?Sized> Eq for NonNull<T> {}
17921792
#[stable(feature = "nonnull", since = "1.25.0")]
17931793
impl<T: ?Sized> PartialEq for NonNull<T> {
17941794
#[inline]
1795+
#[cfg_attr(not(bootstrap), allow(ambiguous_wide_pointer_comparisons))]
17951796
fn eq(&self, other: &Self) -> bool {
17961797
self.as_ptr() == other.as_ptr()
17971798
}

0 commit comments

Comments
 (0)