Pointer metadata: add tracking issue number
This commit is contained in:
parent
5ade3fe32c
commit
cf000f0408
5 changed files with 16 additions and 16 deletions
|
@ -52,8 +52,8 @@ impl<T: ?Sized> *const T {
|
||||||
///
|
///
|
||||||
/// The pointer can be later reconstructed with [`from_raw_parts`].
|
/// The pointer can be later reconstructed with [`from_raw_parts`].
|
||||||
#[cfg(not(bootstrap))]
|
#[cfg(not(bootstrap))]
|
||||||
#[unstable(feature = "ptr_metadata", issue = /* FIXME */ "none")]
|
#[unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = /* FIXME */ "none")]
|
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn to_raw_parts(self) -> (*const (), <T as super::Pointee>::Metadata) {
|
pub const fn to_raw_parts(self) -> (*const (), <T as super::Pointee>::Metadata) {
|
||||||
(self.cast(), super::metadata(self))
|
(self.cast(), super::metadata(self))
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#![unstable(feature = "ptr_metadata", issue = /* FIXME */ "none")]
|
#![unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
|
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::hash::{Hash, Hasher};
|
use crate::hash::{Hash, Hasher};
|
||||||
|
@ -72,7 +72,7 @@ pub trait Pointee {
|
||||||
/// assert_eq!(std::mem::size_of::<&T>(), std::mem::size_of::<usize>())
|
/// assert_eq!(std::mem::size_of::<&T>(), std::mem::size_of::<usize>())
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "ptr_metadata", issue = /* FIXME */ "none")]
|
#[unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
// NOTE: don’t stabilize this before trait aliases are stable in the language?
|
// NOTE: don’t stabilize this before trait aliases are stable in the language?
|
||||||
pub trait Thin = Pointee<Metadata = ()>;
|
pub trait Thin = Pointee<Metadata = ()>;
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ pub trait Thin = Pointee<Metadata = ()>;
|
||||||
///
|
///
|
||||||
/// assert_eq!(std::ptr::metadata("foo"), 3_usize);
|
/// assert_eq!(std::ptr::metadata("foo"), 3_usize);
|
||||||
/// ```
|
/// ```
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = /* FIXME */ "none")]
|
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {
|
pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {
|
||||||
// SAFETY: Accessing the value from the `PtrRepr` union is safe since *const T
|
// SAFETY: Accessing the value from the `PtrRepr` union is safe since *const T
|
||||||
|
@ -104,8 +104,8 @@ pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {
|
||||||
/// For trait objects, the metadata must come from a pointer to the same underlying ereased type.
|
/// For trait objects, the metadata must come from a pointer to the same underlying ereased type.
|
||||||
///
|
///
|
||||||
/// [`slice::from_raw_parts`]: crate::slice::from_raw_parts
|
/// [`slice::from_raw_parts`]: crate::slice::from_raw_parts
|
||||||
#[unstable(feature = "ptr_metadata", issue = /* FIXME */ "none")]
|
#[unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = /* FIXME */ "none")]
|
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn from_raw_parts<T: ?Sized>(
|
pub const fn from_raw_parts<T: ?Sized>(
|
||||||
data_address: *const (),
|
data_address: *const (),
|
||||||
|
@ -121,8 +121,8 @@ pub const fn from_raw_parts<T: ?Sized>(
|
||||||
/// raw `*mut` pointer is returned, as opposed to a raw `*const` pointer.
|
/// raw `*mut` pointer is returned, as opposed to a raw `*const` pointer.
|
||||||
///
|
///
|
||||||
/// See the documentation of [`from_raw_parts`] for more details.
|
/// See the documentation of [`from_raw_parts`] for more details.
|
||||||
#[unstable(feature = "ptr_metadata", issue = /* FIXME */ "none")]
|
#[unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = /* FIXME */ "none")]
|
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn from_raw_parts_mut<T: ?Sized>(
|
pub const fn from_raw_parts_mut<T: ?Sized>(
|
||||||
data_address: *mut (),
|
data_address: *mut (),
|
||||||
|
|
|
@ -87,7 +87,7 @@ mod metadata;
|
||||||
#[cfg(not(bootstrap))]
|
#[cfg(not(bootstrap))]
|
||||||
pub(crate) use metadata::PtrRepr;
|
pub(crate) use metadata::PtrRepr;
|
||||||
#[cfg(not(bootstrap))]
|
#[cfg(not(bootstrap))]
|
||||||
#[unstable(feature = "ptr_metadata", issue = /* FIXME */ "none")]
|
#[unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
pub use metadata::{from_raw_parts, from_raw_parts_mut, metadata, DynMetadata, Pointee, Thin};
|
pub use metadata::{from_raw_parts, from_raw_parts_mut, metadata, DynMetadata, Pointee, Thin};
|
||||||
|
|
||||||
mod non_null;
|
mod non_null;
|
||||||
|
|
|
@ -51,8 +51,8 @@ impl<T: ?Sized> *mut T {
|
||||||
///
|
///
|
||||||
/// The pointer can be later reconstructed with [`from_raw_parts_mut`].
|
/// The pointer can be later reconstructed with [`from_raw_parts_mut`].
|
||||||
#[cfg(not(bootstrap))]
|
#[cfg(not(bootstrap))]
|
||||||
#[unstable(feature = "ptr_metadata", issue = /* FIXME */ "none")]
|
#[unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = /* FIXME */ "none")]
|
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn to_raw_parts(self) -> (*mut (), <T as super::Pointee>::Metadata) {
|
pub const fn to_raw_parts(self) -> (*mut (), <T as super::Pointee>::Metadata) {
|
||||||
(self.cast(), super::metadata(self))
|
(self.cast(), super::metadata(self))
|
||||||
|
|
|
@ -182,8 +182,8 @@ impl<T: ?Sized> NonNull<T> {
|
||||||
///
|
///
|
||||||
/// [`std::ptr::from_raw_parts`]: crate::ptr::from_raw_parts
|
/// [`std::ptr::from_raw_parts`]: crate::ptr::from_raw_parts
|
||||||
#[cfg(not(bootstrap))]
|
#[cfg(not(bootstrap))]
|
||||||
#[unstable(feature = "ptr_metadata", issue = /* FIXME */ "none")]
|
#[unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = /* FIXME */ "none")]
|
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn from_raw_parts(
|
pub const fn from_raw_parts(
|
||||||
data_address: NonNull<()>,
|
data_address: NonNull<()>,
|
||||||
|
@ -199,8 +199,8 @@ impl<T: ?Sized> NonNull<T> {
|
||||||
///
|
///
|
||||||
/// The pointer can be later reconstructed with [`NonNull::from_raw_parts`].
|
/// The pointer can be later reconstructed with [`NonNull::from_raw_parts`].
|
||||||
#[cfg(not(bootstrap))]
|
#[cfg(not(bootstrap))]
|
||||||
#[unstable(feature = "ptr_metadata", issue = /* FIXME */ "none")]
|
#[unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = /* FIXME */ "none")]
|
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn to_raw_parts(self) -> (NonNull<()>, <T as super::Pointee>::Metadata) {
|
pub const fn to_raw_parts(self) -> (NonNull<()>, <T as super::Pointee>::Metadata) {
|
||||||
(self.cast(), super::metadata(self.as_ptr()))
|
(self.cast(), super::metadata(self.as_ptr()))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue