Skip to content

Commit

Permalink
Rollup merge of #117968 - Urgau:stabilize-ptr-addr-eq, r=dtolnay
Browse files Browse the repository at this point in the history
Stabilize `ptr::addr_eq`

This PR stabilize the `ptr_addr_eq` library feature, representing:

```rust
// core::ptr

pub fn addr_eq<T: ?Sized, U: ?Sized>(p: *const T, q: *const U) -> bool;
```

FCP has already started [on the tracking issue](#116324 (comment)) and is waiting on the final period comment.

Note: stabilizing this feature is somewhat of requirement for a new T-lang lint, cf. #117758 (comment).
  • Loading branch information
compiler-errors committed Nov 25, 2023
2 parents fd1a263 + 8d91d66 commit fcb9fcc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion library/alloc/src/lib.rs
Expand Up @@ -140,7 +140,6 @@
#![feature(maybe_uninit_uninit_array)]
#![feature(maybe_uninit_uninit_array_transpose)]
#![feature(pattern)]
#![feature(ptr_addr_eq)]
#![feature(ptr_internals)]
#![feature(ptr_metadata)]
#![feature(ptr_sub_ptr)]
Expand Down
9 changes: 5 additions & 4 deletions library/core/src/ptr/mod.rs
Expand Up @@ -1898,14 +1898,15 @@ pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
/// # Examples
///
/// ```
/// #![feature(ptr_addr_eq)]
/// use std::ptr;
///
/// let whole: &[i32; 3] = &[1, 2, 3];
/// let first: &i32 = &whole[0];
/// assert!(std::ptr::addr_eq(whole, first));
/// assert!(!std::ptr::eq::<dyn std::fmt::Debug>(whole, first));
///
/// assert!(ptr::addr_eq(whole, first));
/// assert!(!ptr::eq::<dyn std::fmt::Debug>(whole, first));
/// ```
#[unstable(feature = "ptr_addr_eq", issue = "116324")]
#[stable(feature = "ptr_addr_eq", since = "CURRENT_RUSTC_VERSION")]
#[inline(always)]
#[must_use = "pointer comparison produces a value"]
pub fn addr_eq<T: ?Sized, U: ?Sized>(p: *const T, q: *const U) -> bool {
Expand Down

0 comments on commit fcb9fcc

Please sign in to comment.