Skip to content

Commit cebe393

Browse files
authored
Rollup merge of #116351 - asquared31415:ptr_eq_must_use, r=workingjubilee
Add `must_use` on pointer equality functions `ptr == ptr` (like all use of `==`) has a similar warning, and these functions are simple convenience wrappers over that.
2 parents 634e5c9 + 34ea540 commit cebe393

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/core/src/ptr/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,7 @@ pub(crate) const unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usiz
18641864
/// ```
18651865
#[stable(feature = "ptr_eq", since = "1.17.0")]
18661866
#[inline(always)]
1867+
#[must_use = "pointer comparison produces a value"]
18671868
pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
18681869
a == b
18691870
}
@@ -1886,6 +1887,7 @@ pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
18861887
/// ```
18871888
#[unstable(feature = "ptr_addr_eq", issue = "116324")]
18881889
#[inline(always)]
1890+
#[must_use = "pointer comparison produces a value"]
18891891
pub fn addr_eq<T: ?Sized, U: ?Sized>(p: *const T, q: *const U) -> bool {
18901892
(p as *const ()) == (q as *const ())
18911893
}

0 commit comments

Comments
 (0)