Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8b4995a

Browse files
committedNov 20, 2024
Make PointerLike opt-in as a trait
1 parent e26c298 commit 8b4995a

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed
 

‎alloc/src/boxed.rs

+6
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ use core::error::{self, Error};
191191
use core::fmt;
192192
use core::future::Future;
193193
use core::hash::{Hash, Hasher};
194+
#[cfg(not(bootstrap))]
195+
use core::marker::PointerLike;
194196
use core::marker::{Tuple, Unsize};
195197
use core::mem::{self, SizedTypeProperties};
196198
use core::ops::{
@@ -2131,3 +2133,7 @@ impl<E: Error> Error for Box<E> {
21312133
Error::provide(&**self, request);
21322134
}
21332135
}
2136+
2137+
#[cfg(not(bootstrap))]
2138+
#[unstable(feature = "pointer_like_trait", issue = "none")]
2139+
impl<T> PointerLike for Box<T> {}

‎alloc/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
#![feature(panic_internals)]
137137
#![feature(pattern)]
138138
#![feature(pin_coerce_unsized_trait)]
139+
#![feature(pointer_like_trait)]
139140
#![feature(ptr_internals)]
140141
#![feature(ptr_metadata)]
141142
#![feature(ptr_sub_ptr)]

‎core/src/marker.rs

+12
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,18 @@ pub trait Tuple {}
981981
)]
982982
pub trait PointerLike {}
983983

984+
#[cfg(not(bootstrap))]
985+
marker_impls! {
986+
#[unstable(feature = "pointer_like_trait", issue = "none")]
987+
PointerLike for
988+
usize,
989+
{T} &T,
990+
{T} &mut T,
991+
{T} *const T,
992+
{T} *mut T,
993+
{T: PointerLike} crate::pin::Pin<T>,
994+
}
995+
984996
/// A marker for types which can be used as types of `const` generic parameters.
985997
///
986998
/// These types must have a proper equivalence relation (`Eq`) and it must be automatically

0 commit comments

Comments
 (0)
Failed to load comments.