make ptr metadata functions callable from stable const fn
This commit is contained in:
parent
58420a065b
commit
5c3ceb3bd9
@ -3160,7 +3160,7 @@ pub const fn type_id<T: ?Sized + 'static>() -> u128 {
|
|||||||
/// change the possible layouts of pointers.
|
/// change the possible layouts of pointers.
|
||||||
#[rustc_nounwind]
|
#[rustc_nounwind]
|
||||||
#[unstable(feature = "core_intrinsics", issue = "none")]
|
#[unstable(feature = "core_intrinsics", issue = "none")]
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[rustc_intrinsic]
|
#[rustc_intrinsic]
|
||||||
#[rustc_intrinsic_must_be_overridden]
|
#[rustc_intrinsic_must_be_overridden]
|
||||||
pub const fn aggregate_raw_ptr<P: AggregateRawPtr<D, Metadata = M>, D, M>(_data: D, _meta: M) -> P {
|
pub const fn aggregate_raw_ptr<P: AggregateRawPtr<D, Metadata = M>, D, M>(_data: D, _meta: M) -> P {
|
||||||
@ -3185,7 +3185,7 @@ impl<P: ?Sized, T: ptr::Thin> AggregateRawPtr<*mut T> for *mut P {
|
|||||||
/// This is used to implement functions like `ptr::metadata`.
|
/// This is used to implement functions like `ptr::metadata`.
|
||||||
#[rustc_nounwind]
|
#[rustc_nounwind]
|
||||||
#[unstable(feature = "core_intrinsics", issue = "none")]
|
#[unstable(feature = "core_intrinsics", issue = "none")]
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[rustc_intrinsic]
|
#[rustc_intrinsic]
|
||||||
#[rustc_intrinsic_must_be_overridden]
|
#[rustc_intrinsic_must_be_overridden]
|
||||||
pub const fn ptr_metadata<P: ptr::Pointee<Metadata = M> + ?Sized, M>(_ptr: *const P) -> M {
|
pub const fn ptr_metadata<P: ptr::Pointee<Metadata = M> + ?Sized, M>(_ptr: *const P) -> M {
|
||||||
|
@ -92,7 +92,7 @@ pub const fn cast<U>(self) -> *const U {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "set_ptr_value", issue = "75091")]
|
#[unstable(feature = "set_ptr_value", issue = "75091")]
|
||||||
#[rustc_const_unstable(feature = "set_ptr_value", issue = "75091")]
|
#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[must_use = "returns a new pointer rather than modifying its argument"]
|
#[must_use = "returns a new pointer rather than modifying its argument"]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn with_metadata_of<U>(self, meta: *const U) -> *const U
|
pub const fn with_metadata_of<U>(self, meta: *const U) -> *const U
|
||||||
@ -412,7 +412,6 @@ pub const fn to_raw_parts(self) -> (*const (), <T as super::Pointee>::Metadata)
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
pub const unsafe fn byte_offset(self, count: isize) -> Self {
|
pub const unsafe fn byte_offset(self, count: isize) -> Self {
|
||||||
// SAFETY: the caller must uphold the safety contract for `offset`.
|
// SAFETY: the caller must uphold the safety contract for `offset`.
|
||||||
@ -495,7 +494,6 @@ pub const fn wrapping_offset(self, count: isize) -> *const T
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
pub const fn wrapping_byte_offset(self, count: isize) -> Self {
|
pub const fn wrapping_byte_offset(self, count: isize) -> Self {
|
||||||
self.cast::<u8>().wrapping_offset(count).with_metadata_of(self)
|
self.cast::<u8>().wrapping_offset(count).with_metadata_of(self)
|
||||||
}
|
}
|
||||||
@ -645,7 +643,6 @@ pub fn mask(self, mask: usize) -> *const T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize {
|
pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize {
|
||||||
// SAFETY: the caller must uphold the safety contract for `offset_from`.
|
// SAFETY: the caller must uphold the safety contract for `offset_from`.
|
||||||
@ -873,7 +870,6 @@ pub const fn guaranteed_ne(self, other: *const T) -> Option<bool>
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
pub const unsafe fn byte_add(self, count: usize) -> Self {
|
pub const unsafe fn byte_add(self, count: usize) -> Self {
|
||||||
// SAFETY: the caller must uphold the safety contract for `add`.
|
// SAFETY: the caller must uphold the safety contract for `add`.
|
||||||
@ -956,7 +952,6 @@ pub const fn guaranteed_ne(self, other: *const T) -> Option<bool>
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
pub const unsafe fn byte_sub(self, count: usize) -> Self {
|
pub const unsafe fn byte_sub(self, count: usize) -> Self {
|
||||||
// SAFETY: the caller must uphold the safety contract for `sub`.
|
// SAFETY: the caller must uphold the safety contract for `sub`.
|
||||||
@ -1039,7 +1034,6 @@ pub const fn wrapping_add(self, count: usize) -> Self
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
pub const fn wrapping_byte_add(self, count: usize) -> Self {
|
pub const fn wrapping_byte_add(self, count: usize) -> Self {
|
||||||
self.cast::<u8>().wrapping_add(count).with_metadata_of(self)
|
self.cast::<u8>().wrapping_add(count).with_metadata_of(self)
|
||||||
}
|
}
|
||||||
@ -1120,7 +1114,6 @@ pub const fn wrapping_sub(self, count: usize) -> Self
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
pub const fn wrapping_byte_sub(self, count: usize) -> Self {
|
pub const fn wrapping_byte_sub(self, count: usize) -> Self {
|
||||||
self.cast::<u8>().wrapping_sub(count).with_metadata_of(self)
|
self.cast::<u8>().wrapping_sub(count).with_metadata_of(self)
|
||||||
}
|
}
|
||||||
@ -1554,7 +1547,6 @@ impl<T> *const [T] {
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "slice_ptr_len", since = "1.79.0")]
|
#[stable(feature = "slice_ptr_len", since = "1.79.0")]
|
||||||
#[rustc_const_stable(feature = "const_slice_ptr_len", since = "1.79.0")]
|
#[rustc_const_stable(feature = "const_slice_ptr_len", since = "1.79.0")]
|
||||||
#[rustc_allow_const_fn_unstable(ptr_metadata)]
|
|
||||||
pub const fn len(self) -> usize {
|
pub const fn len(self) -> usize {
|
||||||
metadata(self)
|
metadata(self)
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ pub trait Pointee {
|
|||||||
///
|
///
|
||||||
/// assert_eq!(std::ptr::metadata("foo"), 3_usize);
|
/// assert_eq!(std::ptr::metadata("foo"), 3_usize);
|
||||||
/// ```
|
/// ```
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[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 {
|
||||||
ptr_metadata(ptr)
|
ptr_metadata(ptr)
|
||||||
@ -106,7 +106,7 @@ pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {
|
|||||||
///
|
///
|
||||||
/// [`slice::from_raw_parts`]: crate::slice::from_raw_parts
|
/// [`slice::from_raw_parts`]: crate::slice::from_raw_parts
|
||||||
#[unstable(feature = "ptr_metadata", issue = "81513")]
|
#[unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn from_raw_parts<T: ?Sized>(
|
pub const fn from_raw_parts<T: ?Sized>(
|
||||||
data_pointer: *const impl Thin,
|
data_pointer: *const impl Thin,
|
||||||
@ -120,7 +120,7 @@ pub const fn from_raw_parts<T: ?Sized>(
|
|||||||
///
|
///
|
||||||
/// 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 = "81513")]
|
#[unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn from_raw_parts_mut<T: ?Sized>(
|
pub const fn from_raw_parts_mut<T: ?Sized>(
|
||||||
data_pointer: *mut impl Thin,
|
data_pointer: *mut impl Thin,
|
||||||
|
@ -599,7 +599,6 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
|
|||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_promotable]
|
#[rustc_promotable]
|
||||||
#[rustc_const_stable(feature = "const_ptr_null", since = "1.24.0")]
|
#[rustc_const_stable(feature = "const_ptr_null", since = "1.24.0")]
|
||||||
#[rustc_allow_const_fn_unstable(ptr_metadata)]
|
|
||||||
#[rustc_diagnostic_item = "ptr_null"]
|
#[rustc_diagnostic_item = "ptr_null"]
|
||||||
pub const fn null<T: ?Sized + Thin>() -> *const T {
|
pub const fn null<T: ?Sized + Thin>() -> *const T {
|
||||||
from_raw_parts(without_provenance::<()>(0), ())
|
from_raw_parts(without_provenance::<()>(0), ())
|
||||||
@ -625,7 +624,6 @@ pub const fn null<T: ?Sized + Thin>() -> *const T {
|
|||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_promotable]
|
#[rustc_promotable]
|
||||||
#[rustc_const_stable(feature = "const_ptr_null", since = "1.24.0")]
|
#[rustc_const_stable(feature = "const_ptr_null", since = "1.24.0")]
|
||||||
#[rustc_allow_const_fn_unstable(ptr_metadata)]
|
|
||||||
#[rustc_diagnostic_item = "ptr_null_mut"]
|
#[rustc_diagnostic_item = "ptr_null_mut"]
|
||||||
pub const fn null_mut<T: ?Sized + Thin>() -> *mut T {
|
pub const fn null_mut<T: ?Sized + Thin>() -> *mut T {
|
||||||
from_raw_parts_mut(without_provenance_mut::<()>(0), ())
|
from_raw_parts_mut(without_provenance_mut::<()>(0), ())
|
||||||
@ -949,7 +947,6 @@ pub const fn from_mut<T: ?Sized>(r: &mut T) -> *mut T {
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "slice_from_raw_parts", since = "1.42.0")]
|
#[stable(feature = "slice_from_raw_parts", since = "1.42.0")]
|
||||||
#[rustc_const_stable(feature = "const_slice_from_raw_parts", since = "1.64.0")]
|
#[rustc_const_stable(feature = "const_slice_from_raw_parts", since = "1.64.0")]
|
||||||
#[rustc_allow_const_fn_unstable(ptr_metadata)]
|
|
||||||
#[rustc_diagnostic_item = "ptr_slice_from_raw_parts"]
|
#[rustc_diagnostic_item = "ptr_slice_from_raw_parts"]
|
||||||
pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
|
pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
|
||||||
from_raw_parts(data, len)
|
from_raw_parts(data, len)
|
||||||
|
@ -74,7 +74,7 @@ pub const fn cast<U>(self) -> *mut U {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "set_ptr_value", issue = "75091")]
|
#[unstable(feature = "set_ptr_value", issue = "75091")]
|
||||||
#[rustc_const_unstable(feature = "set_ptr_value", issue = "75091")]
|
#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[must_use = "returns a new pointer rather than modifying its argument"]
|
#[must_use = "returns a new pointer rather than modifying its argument"]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn with_metadata_of<U>(self, meta: *const U) -> *mut U
|
pub const fn with_metadata_of<U>(self, meta: *const U) -> *mut U
|
||||||
@ -412,7 +412,6 @@ pub const fn to_raw_parts(self) -> (*mut (), <T as super::Pointee>::Metadata) {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
pub const unsafe fn byte_offset(self, count: isize) -> Self {
|
pub const unsafe fn byte_offset(self, count: isize) -> Self {
|
||||||
// SAFETY: the caller must uphold the safety contract for `offset`.
|
// SAFETY: the caller must uphold the safety contract for `offset`.
|
||||||
@ -492,7 +491,6 @@ pub const fn wrapping_offset(self, count: isize) -> *mut T
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
pub const fn wrapping_byte_offset(self, count: isize) -> Self {
|
pub const fn wrapping_byte_offset(self, count: isize) -> Self {
|
||||||
self.cast::<u8>().wrapping_offset(count).with_metadata_of(self)
|
self.cast::<u8>().wrapping_offset(count).with_metadata_of(self)
|
||||||
}
|
}
|
||||||
@ -808,7 +806,6 @@ pub const fn guaranteed_ne(self, other: *mut T) -> Option<bool>
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize {
|
pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize {
|
||||||
// SAFETY: the caller must uphold the safety contract for `offset_from`.
|
// SAFETY: the caller must uphold the safety contract for `offset_from`.
|
||||||
@ -954,7 +951,6 @@ pub const fn guaranteed_ne(self, other: *mut T) -> Option<bool>
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
pub const unsafe fn byte_add(self, count: usize) -> Self {
|
pub const unsafe fn byte_add(self, count: usize) -> Self {
|
||||||
// SAFETY: the caller must uphold the safety contract for `add`.
|
// SAFETY: the caller must uphold the safety contract for `add`.
|
||||||
@ -1037,7 +1033,6 @@ pub const fn guaranteed_ne(self, other: *mut T) -> Option<bool>
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
pub const unsafe fn byte_sub(self, count: usize) -> Self {
|
pub const unsafe fn byte_sub(self, count: usize) -> Self {
|
||||||
// SAFETY: the caller must uphold the safety contract for `sub`.
|
// SAFETY: the caller must uphold the safety contract for `sub`.
|
||||||
@ -1118,7 +1113,6 @@ pub const fn wrapping_add(self, count: usize) -> Self
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
pub const fn wrapping_byte_add(self, count: usize) -> Self {
|
pub const fn wrapping_byte_add(self, count: usize) -> Self {
|
||||||
self.cast::<u8>().wrapping_add(count).with_metadata_of(self)
|
self.cast::<u8>().wrapping_add(count).with_metadata_of(self)
|
||||||
}
|
}
|
||||||
@ -1197,7 +1191,6 @@ pub const fn wrapping_sub(self, count: usize) -> Self
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
pub const fn wrapping_byte_sub(self, count: usize) -> Self {
|
pub const fn wrapping_byte_sub(self, count: usize) -> Self {
|
||||||
self.cast::<u8>().wrapping_sub(count).with_metadata_of(self)
|
self.cast::<u8>().wrapping_sub(count).with_metadata_of(self)
|
||||||
}
|
}
|
||||||
@ -1804,7 +1797,6 @@ impl<T> *mut [T] {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "slice_ptr_len", since = "1.79.0")]
|
#[stable(feature = "slice_ptr_len", since = "1.79.0")]
|
||||||
#[rustc_const_stable(feature = "const_slice_ptr_len", since = "1.79.0")]
|
#[rustc_const_stable(feature = "const_slice_ptr_len", since = "1.79.0")]
|
||||||
#[rustc_allow_const_fn_unstable(ptr_metadata)]
|
|
||||||
pub const fn len(self) -> usize {
|
pub const fn len(self) -> usize {
|
||||||
metadata(self)
|
metadata(self)
|
||||||
}
|
}
|
||||||
|
@ -567,7 +567,6 @@ pub const fn cast<U>(self) -> NonNull<U> {
|
|||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[stable(feature = "non_null_convenience", since = "1.80.0")]
|
#[stable(feature = "non_null_convenience", since = "1.80.0")]
|
||||||
#[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")]
|
#[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")]
|
||||||
pub const unsafe fn byte_add(self, count: usize) -> Self {
|
pub const unsafe fn byte_add(self, count: usize) -> Self {
|
||||||
@ -651,7 +650,6 @@ pub const fn cast<U>(self) -> NonNull<U> {
|
|||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[stable(feature = "non_null_convenience", since = "1.80.0")]
|
#[stable(feature = "non_null_convenience", since = "1.80.0")]
|
||||||
#[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")]
|
#[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")]
|
||||||
pub const unsafe fn byte_sub(self, count: usize) -> Self {
|
pub const unsafe fn byte_sub(self, count: usize) -> Self {
|
||||||
|
@ -111,7 +111,6 @@ impl<T> [T] {
|
|||||||
#[lang = "slice_len_fn"]
|
#[lang = "slice_len_fn"]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_const_stable(feature = "const_slice_len", since = "1.39.0")]
|
#[rustc_const_stable(feature = "const_slice_len", since = "1.39.0")]
|
||||||
#[rustc_allow_const_fn_unstable(ptr_metadata)]
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn len(&self) -> usize {
|
pub const fn len(&self) -> usize {
|
||||||
|
Loading…
Reference in New Issue
Block a user