Skip to content

Commit 34ea540

Browse files
committed
add must_use on pointer equality functions
1 parent b0889cb commit 34ea540

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)