add miri-track-caller to some intrinsic-exposing methods

This commit is contained in:
Ralf Jung 2022-07-24 14:28:30 -04:00
parent 35a0617248
commit d10a7b1243
7 changed files with 38 additions and 0 deletions

View File

@ -96,6 +96,7 @@ use crate::intrinsics;
#[inline] #[inline]
#[stable(feature = "unreachable", since = "1.27.0")] #[stable(feature = "unreachable", since = "1.27.0")]
#[rustc_const_stable(feature = "const_unreachable_unchecked", since = "1.57.0")] #[rustc_const_stable(feature = "const_unreachable_unchecked", since = "1.57.0")]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn unreachable_unchecked() -> ! { pub const unsafe fn unreachable_unchecked() -> ! {
// SAFETY: the safety contract for `intrinsics::unreachable` must // SAFETY: the safety contract for `intrinsics::unreachable` must
// be upheld by the caller. // be upheld by the caller.

View File

@ -2449,6 +2449,7 @@ pub(crate) fn is_nonoverlapping<T>(src: *const T, dst: *const T, count: usize) -
#[cfg_attr(not(bootstrap), rustc_allowed_through_unstable_modules)] #[cfg_attr(not(bootstrap), rustc_allowed_through_unstable_modules)]
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) { pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
extern "rust-intrinsic" { extern "rust-intrinsic" {
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
@ -2535,6 +2536,7 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
#[cfg_attr(not(bootstrap), rustc_allowed_through_unstable_modules)] #[cfg_attr(not(bootstrap), rustc_allowed_through_unstable_modules)]
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) { pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
extern "rust-intrinsic" { extern "rust-intrinsic" {
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]

View File

@ -1124,6 +1124,7 @@ impl<T> fmt::Debug for Discriminant<T> {
#[stable(feature = "discriminant_value", since = "1.21.0")] #[stable(feature = "discriminant_value", since = "1.21.0")]
#[rustc_const_unstable(feature = "const_discriminant", issue = "69821")] #[rustc_const_unstable(feature = "const_discriminant", issue = "69821")]
#[cfg_attr(not(test), rustc_diagnostic_item = "mem_discriminant")] #[cfg_attr(not(test), rustc_diagnostic_item = "mem_discriminant")]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const fn discriminant<T>(v: &T) -> Discriminant<T> { pub const fn discriminant<T>(v: &T) -> Discriminant<T> {
Discriminant(intrinsics::discriminant_value(v)) Discriminant(intrinsics::discriminant_value(v))
} }

View File

@ -449,6 +449,7 @@ macro_rules! int_impl {
without modifying the original"] without modifying the original"]
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")] #[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn unchecked_add(self, rhs: Self) -> Self { pub const unsafe fn unchecked_add(self, rhs: Self) -> Self {
// SAFETY: the caller must uphold the safety contract for // SAFETY: the caller must uphold the safety contract for
// `unchecked_add`. // `unchecked_add`.
@ -517,6 +518,7 @@ macro_rules! int_impl {
without modifying the original"] without modifying the original"]
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")] #[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn unchecked_sub(self, rhs: Self) -> Self { pub const unsafe fn unchecked_sub(self, rhs: Self) -> Self {
// SAFETY: the caller must uphold the safety contract for // SAFETY: the caller must uphold the safety contract for
// `unchecked_sub`. // `unchecked_sub`.
@ -585,6 +587,7 @@ macro_rules! int_impl {
without modifying the original"] without modifying the original"]
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")] #[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn unchecked_mul(self, rhs: Self) -> Self { pub const unsafe fn unchecked_mul(self, rhs: Self) -> Self {
// SAFETY: the caller must uphold the safety contract for // SAFETY: the caller must uphold the safety contract for
// `unchecked_mul`. // `unchecked_mul`.
@ -757,6 +760,7 @@ macro_rules! int_impl {
without modifying the original"] without modifying the original"]
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")] #[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn unchecked_shl(self, rhs: Self) -> Self { pub const unsafe fn unchecked_shl(self, rhs: Self) -> Self {
// SAFETY: the caller must uphold the safety contract for // SAFETY: the caller must uphold the safety contract for
// `unchecked_shl`. // `unchecked_shl`.
@ -803,6 +807,7 @@ macro_rules! int_impl {
without modifying the original"] without modifying the original"]
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")] #[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn unchecked_shr(self, rhs: Self) -> Self { pub const unsafe fn unchecked_shr(self, rhs: Self) -> Self {
// SAFETY: the caller must uphold the safety contract for // SAFETY: the caller must uphold the safety contract for
// `unchecked_shr`. // `unchecked_shr`.

View File

@ -459,6 +459,7 @@ macro_rules! uint_impl {
without modifying the original"] without modifying the original"]
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")] #[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn unchecked_add(self, rhs: Self) -> Self { pub const unsafe fn unchecked_add(self, rhs: Self) -> Self {
// SAFETY: the caller must uphold the safety contract for // SAFETY: the caller must uphold the safety contract for
// `unchecked_add`. // `unchecked_add`.
@ -528,6 +529,7 @@ macro_rules! uint_impl {
without modifying the original"] without modifying the original"]
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")] #[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn unchecked_sub(self, rhs: Self) -> Self { pub const unsafe fn unchecked_sub(self, rhs: Self) -> Self {
// SAFETY: the caller must uphold the safety contract for // SAFETY: the caller must uphold the safety contract for
// `unchecked_sub`. // `unchecked_sub`.
@ -574,6 +576,7 @@ macro_rules! uint_impl {
without modifying the original"] without modifying the original"]
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")] #[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn unchecked_mul(self, rhs: Self) -> Self { pub const unsafe fn unchecked_mul(self, rhs: Self) -> Self {
// SAFETY: the caller must uphold the safety contract for // SAFETY: the caller must uphold the safety contract for
// `unchecked_mul`. // `unchecked_mul`.
@ -933,6 +936,7 @@ macro_rules! uint_impl {
without modifying the original"] without modifying the original"]
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")] #[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn unchecked_shl(self, rhs: Self) -> Self { pub const unsafe fn unchecked_shl(self, rhs: Self) -> Self {
// SAFETY: the caller must uphold the safety contract for // SAFETY: the caller must uphold the safety contract for
// `unchecked_shl`. // `unchecked_shl`.
@ -979,6 +983,7 @@ macro_rules! uint_impl {
without modifying the original"] without modifying the original"]
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")] #[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn unchecked_shr(self, rhs: Self) -> Self { pub const unsafe fn unchecked_shr(self, rhs: Self) -> Self {
// SAFETY: the caller must uphold the safety contract for // SAFETY: the caller must uphold the safety contract for
// `unchecked_shr`. // `unchecked_shr`.

View File

@ -449,6 +449,7 @@ impl<T: ?Sized> *const T {
#[must_use = "returns a new pointer rather than modifying its argument"] #[must_use = "returns a new pointer rather than modifying its argument"]
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")] #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn offset(self, count: isize) -> *const T pub const unsafe fn offset(self, count: isize) -> *const T
where where
T: Sized, T: Sized,
@ -471,6 +472,7 @@ impl<T: ?Sized> *const T {
#[inline(always)] #[inline(always)]
#[unstable(feature = "pointer_byte_offsets", issue = "96283")] #[unstable(feature = "pointer_byte_offsets", issue = "96283")]
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")] #[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
#[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`.
let this = unsafe { self.cast::<u8>().offset(count).cast::<()>() }; let this = unsafe { self.cast::<u8>().offset(count).cast::<()>() };
@ -641,6 +643,7 @@ impl<T: ?Sized> *const T {
#[stable(feature = "ptr_offset_from", since = "1.47.0")] #[stable(feature = "ptr_offset_from", since = "1.47.0")]
#[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")] #[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")]
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn offset_from(self, origin: *const T) -> isize pub const unsafe fn offset_from(self, origin: *const T) -> isize
where where
T: Sized, T: Sized,
@ -663,6 +666,7 @@ impl<T: ?Sized> *const T {
#[inline(always)] #[inline(always)]
#[unstable(feature = "pointer_byte_offsets", issue = "96283")] #[unstable(feature = "pointer_byte_offsets", issue = "96283")]
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")] #[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn byte_offset_from(self, origin: *const T) -> isize { pub const unsafe fn byte_offset_from(self, origin: *const T) -> isize {
// SAFETY: the caller must uphold the safety contract for `offset_from`. // SAFETY: the caller must uphold the safety contract for `offset_from`.
unsafe { self.cast::<u8>().offset_from(origin.cast::<u8>()) } unsafe { self.cast::<u8>().offset_from(origin.cast::<u8>()) }
@ -731,6 +735,7 @@ impl<T: ?Sized> *const T {
#[unstable(feature = "ptr_sub_ptr", issue = "95892")] #[unstable(feature = "ptr_sub_ptr", issue = "95892")]
#[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")]
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn sub_ptr(self, origin: *const T) -> usize pub const unsafe fn sub_ptr(self, origin: *const T) -> usize
where where
T: Sized, T: Sized,
@ -862,6 +867,7 @@ impl<T: ?Sized> *const T {
#[must_use = "returns a new pointer rather than modifying its argument"] #[must_use = "returns a new pointer rather than modifying its argument"]
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")] #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn add(self, count: usize) -> Self pub const unsafe fn add(self, count: usize) -> Self
where where
T: Sized, T: Sized,
@ -884,6 +890,7 @@ impl<T: ?Sized> *const T {
#[inline(always)] #[inline(always)]
#[unstable(feature = "pointer_byte_offsets", issue = "96283")] #[unstable(feature = "pointer_byte_offsets", issue = "96283")]
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")] #[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
#[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`.
let this = unsafe { self.cast::<u8>().add(count).cast::<()>() }; let this = unsafe { self.cast::<u8>().add(count).cast::<()>() };
@ -946,6 +953,7 @@ impl<T: ?Sized> *const T {
#[must_use = "returns a new pointer rather than modifying its argument"] #[must_use = "returns a new pointer rather than modifying its argument"]
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")] #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn sub(self, count: usize) -> Self pub const unsafe fn sub(self, count: usize) -> Self
where where
T: Sized, T: Sized,
@ -969,6 +977,7 @@ impl<T: ?Sized> *const T {
#[inline(always)] #[inline(always)]
#[unstable(feature = "pointer_byte_offsets", issue = "96283")] #[unstable(feature = "pointer_byte_offsets", issue = "96283")]
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")] #[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
#[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`.
let this = unsafe { self.cast::<u8>().sub(count).cast::<()>() }; let this = unsafe { self.cast::<u8>().sub(count).cast::<()>() };
@ -1205,6 +1214,7 @@ impl<T: ?Sized> *const T {
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
#[stable(feature = "pointer_methods", since = "1.26.0")] #[stable(feature = "pointer_methods", since = "1.26.0")]
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn copy_to(self, dest: *mut T, count: usize) pub const unsafe fn copy_to(self, dest: *mut T, count: usize)
where where
T: Sized, T: Sized,
@ -1224,6 +1234,7 @@ impl<T: ?Sized> *const T {
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
#[stable(feature = "pointer_methods", since = "1.26.0")] #[stable(feature = "pointer_methods", since = "1.26.0")]
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize) pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
where where
T: Sized, T: Sized,

View File

@ -461,6 +461,7 @@ impl<T: ?Sized> *mut T {
#[must_use = "returns a new pointer rather than modifying its argument"] #[must_use = "returns a new pointer rather than modifying its argument"]
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")] #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn offset(self, count: isize) -> *mut T pub const unsafe fn offset(self, count: isize) -> *mut T
where where
T: Sized, T: Sized,
@ -485,6 +486,7 @@ impl<T: ?Sized> *mut T {
#[inline(always)] #[inline(always)]
#[unstable(feature = "pointer_byte_offsets", issue = "96283")] #[unstable(feature = "pointer_byte_offsets", issue = "96283")]
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")] #[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
#[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`.
let this = unsafe { self.cast::<u8>().offset(count).cast::<()>() }; let this = unsafe { self.cast::<u8>().offset(count).cast::<()>() };
@ -824,6 +826,7 @@ impl<T: ?Sized> *mut T {
#[stable(feature = "ptr_offset_from", since = "1.47.0")] #[stable(feature = "ptr_offset_from", since = "1.47.0")]
#[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")] #[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn offset_from(self, origin: *const T) -> isize pub const unsafe fn offset_from(self, origin: *const T) -> isize
where where
T: Sized, T: Sized,
@ -844,6 +847,7 @@ impl<T: ?Sized> *mut T {
#[inline(always)] #[inline(always)]
#[unstable(feature = "pointer_byte_offsets", issue = "96283")] #[unstable(feature = "pointer_byte_offsets", issue = "96283")]
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")] #[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn byte_offset_from(self, origin: *const T) -> isize { pub const unsafe fn byte_offset_from(self, origin: *const T) -> isize {
// SAFETY: the caller must uphold the safety contract for `offset_from`. // SAFETY: the caller must uphold the safety contract for `offset_from`.
unsafe { self.cast::<u8>().offset_from(origin.cast::<u8>()) } unsafe { self.cast::<u8>().offset_from(origin.cast::<u8>()) }
@ -913,6 +917,7 @@ impl<T: ?Sized> *mut T {
#[unstable(feature = "ptr_sub_ptr", issue = "95892")] #[unstable(feature = "ptr_sub_ptr", issue = "95892")]
#[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")]
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn sub_ptr(self, origin: *const T) -> usize pub const unsafe fn sub_ptr(self, origin: *const T) -> usize
where where
T: Sized, T: Sized,
@ -976,6 +981,7 @@ impl<T: ?Sized> *mut T {
#[must_use = "returns a new pointer rather than modifying its argument"] #[must_use = "returns a new pointer rather than modifying its argument"]
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")] #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn add(self, count: usize) -> Self pub const unsafe fn add(self, count: usize) -> Self
where where
T: Sized, T: Sized,
@ -998,6 +1004,7 @@ impl<T: ?Sized> *mut T {
#[inline(always)] #[inline(always)]
#[unstable(feature = "pointer_byte_offsets", issue = "96283")] #[unstable(feature = "pointer_byte_offsets", issue = "96283")]
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")] #[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
#[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`.
let this = unsafe { self.cast::<u8>().add(count).cast::<()>() }; let this = unsafe { self.cast::<u8>().add(count).cast::<()>() };
@ -1060,6 +1067,7 @@ impl<T: ?Sized> *mut T {
#[must_use = "returns a new pointer rather than modifying its argument"] #[must_use = "returns a new pointer rather than modifying its argument"]
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")] #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn sub(self, count: usize) -> Self pub const unsafe fn sub(self, count: usize) -> Self
where where
T: Sized, T: Sized,
@ -1083,6 +1091,7 @@ impl<T: ?Sized> *mut T {
#[inline(always)] #[inline(always)]
#[unstable(feature = "pointer_byte_offsets", issue = "96283")] #[unstable(feature = "pointer_byte_offsets", issue = "96283")]
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")] #[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
#[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`.
let this = unsafe { self.cast::<u8>().sub(count).cast::<()>() }; let this = unsafe { self.cast::<u8>().sub(count).cast::<()>() };
@ -1319,6 +1328,7 @@ impl<T: ?Sized> *mut T {
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
#[stable(feature = "pointer_methods", since = "1.26.0")] #[stable(feature = "pointer_methods", since = "1.26.0")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn copy_to(self, dest: *mut T, count: usize) pub const unsafe fn copy_to(self, dest: *mut T, count: usize)
where where
T: Sized, T: Sized,
@ -1338,6 +1348,7 @@ impl<T: ?Sized> *mut T {
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
#[stable(feature = "pointer_methods", since = "1.26.0")] #[stable(feature = "pointer_methods", since = "1.26.0")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize) pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
where where
T: Sized, T: Sized,
@ -1357,6 +1368,7 @@ impl<T: ?Sized> *mut T {
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
#[stable(feature = "pointer_methods", since = "1.26.0")] #[stable(feature = "pointer_methods", since = "1.26.0")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn copy_from(self, src: *const T, count: usize) pub const unsafe fn copy_from(self, src: *const T, count: usize)
where where
T: Sized, T: Sized,
@ -1376,6 +1388,7 @@ impl<T: ?Sized> *mut T {
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
#[stable(feature = "pointer_methods", since = "1.26.0")] #[stable(feature = "pointer_methods", since = "1.26.0")]
#[inline(always)] #[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize) pub const unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize)
where where
T: Sized, T: Sized,