add must_use on pointer equality functions

This commit is contained in:
asquared31415 2023-10-02 15:10:51 +00:00
parent b0889cb4ed
commit 34ea540720

View File

@ -1864,6 +1864,7 @@ pub unsafe fn write_volatile<T>(dst: *mut T, src: T) {
/// ```
#[stable(feature = "ptr_eq", since = "1.17.0")]
#[inline(always)]
#[must_use = "pointer comparison produces a value"]
pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
a == b
}
@ -1886,6 +1887,7 @@ pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
/// ```
#[unstable(feature = "ptr_addr_eq", issue = "116324")]
#[inline(always)]
#[must_use = "pointer comparison produces a value"]
pub fn addr_eq<T: ?Sized, U: ?Sized>(p: *const T, q: *const U) -> bool {
(p as *const ()) == (q as *const ())
}