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.
This commit is contained in:
commit
cebe393a4a
@ -1864,6 +1864,7 @@ pub unsafe fn write_volatile<T>(dst: *mut T, src: T) {
|
|||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "ptr_eq", since = "1.17.0")]
|
#[stable(feature = "ptr_eq", since = "1.17.0")]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
#[must_use = "pointer comparison produces a value"]
|
||||||
pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
|
pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
|
||||||
a == b
|
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")]
|
#[unstable(feature = "ptr_addr_eq", issue = "116324")]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
#[must_use = "pointer comparison produces a value"]
|
||||||
pub fn addr_eq<T: ?Sized, U: ?Sized>(p: *const T, q: *const U) -> bool {
|
pub fn addr_eq<T: ?Sized, U: ?Sized>(p: *const T, q: *const U) -> bool {
|
||||||
(p as *const ()) == (q as *const ())
|
(p as *const ()) == (q as *const ())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user