Skip to content

Commit

Permalink
add must_use on pointer equality functions
Browse files Browse the repository at this point in the history
  • Loading branch information
asquared31415 committed Oct 2, 2023
1 parent b0889cb commit 34ea540
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions library/core/src/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,7 @@ pub(crate) const unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usiz
/// ```
#[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
}
Expand All @@ -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 ())
}
Expand Down

0 comments on commit 34ea540

Please sign in to comment.