Skip to content

Commit

Permalink
Make PointerLike opt-in as a trait
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Nov 20, 2024
1 parent e26c298 commit 8b4995a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ use core::error::{self, Error};
use core::fmt;
use core::future::Future;
use core::hash::{Hash, Hasher};
#[cfg(not(bootstrap))]
use core::marker::PointerLike;
use core::marker::{Tuple, Unsize};
use core::mem::{self, SizedTypeProperties};
use core::ops::{
Expand Down Expand Up @@ -2131,3 +2133,7 @@ impl<E: Error> Error for Box<E> {
Error::provide(&**self, request);
}
}

#[cfg(not(bootstrap))]
#[unstable(feature = "pointer_like_trait", issue = "none")]
impl<T> PointerLike for Box<T> {}
1 change: 1 addition & 0 deletions alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
#![feature(panic_internals)]
#![feature(pattern)]
#![feature(pin_coerce_unsized_trait)]
#![feature(pointer_like_trait)]
#![feature(ptr_internals)]
#![feature(ptr_metadata)]
#![feature(ptr_sub_ptr)]
Expand Down
12 changes: 12 additions & 0 deletions core/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,18 @@ pub trait Tuple {}
)]
pub trait PointerLike {}

#[cfg(not(bootstrap))]
marker_impls! {
#[unstable(feature = "pointer_like_trait", issue = "none")]
PointerLike for
usize,
{T} &T,
{T} &mut T,
{T} *const T,
{T} *mut T,
{T: PointerLike} crate::pin::Pin<T>,
}

/// A marker for types which can be used as types of `const` generic parameters.
///
/// These types must have a proper equivalence relation (`Eq`) and it must be automatically
Expand Down

0 comments on commit 8b4995a

Please sign in to comment.