convert all const-callable intrinsics into the new form (without extern block)

This commit is contained in:
Ralf Jung 2024-11-01 22:09:07 +01:00
parent 82c24eccad
commit 7934f26613

View File

@ -936,6 +936,13 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
#[rustc_nounwind] #[rustc_nounwind]
pub fn abort() -> !; pub fn abort() -> !;
/// Executes a breakpoint trap, for inspection by a debugger.
///
/// This intrinsic does not have a stable counterpart.
#[rustc_nounwind]
pub fn breakpoint();
}
/// Informs the optimizer that this point in the code is not reachable, /// Informs the optimizer that this point in the code is not reachable,
/// enabling further optimizations. /// enabling further optimizations.
/// ///
@ -950,7 +957,10 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
)] )]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn unreachable() -> !; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn unreachable() -> ! {
unreachable!()
} }
/// Informs the optimizer that a condition is always true. /// Informs the optimizer that a condition is always true.
@ -1044,22 +1054,18 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
if b { true_val } else { false_val } if b { true_val } else { false_val }
} }
extern "rust-intrinsic" {
/// Executes a breakpoint trap, for inspection by a debugger.
///
/// This intrinsic does not have a stable counterpart.
#[rustc_nounwind]
pub fn breakpoint();
/// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited: /// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited:
/// This will statically either panic, or do nothing. /// This will statically either panic, or do nothing.
/// ///
/// This intrinsic does not have a stable counterpart. /// This intrinsic does not have a stable counterpart.
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_assert_type", since = "1.59.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_assert_type", since = "1.59.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn assert_inhabited<T>(); #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn assert_inhabited<T>() {
unreachable!()
}
/// A guard for unsafe functions that cannot ever be executed if `T` does not permit /// A guard for unsafe functions that cannot ever be executed if `T` does not permit
/// zero-initialization: This will statically either panic, or do nothing. /// zero-initialization: This will statically either panic, or do nothing.
@ -1067,18 +1073,24 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// This intrinsic does not have a stable counterpart. /// This intrinsic does not have a stable counterpart.
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_assert_type2", since = "1.75.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_assert_type2", since = "1.75.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn assert_zero_valid<T>(); #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn assert_zero_valid<T>() {
unreachable!()
}
/// A guard for `std::mem::uninitialized`. This will statically either panic, or do nothing. /// A guard for `std::mem::uninitialized`. This will statically either panic, or do nothing.
/// ///
/// This intrinsic does not have a stable counterpart. /// This intrinsic does not have a stable counterpart.
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_assert_type2", since = "1.75.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_assert_type2", since = "1.75.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn assert_mem_uninitialized_valid<T>(); #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn assert_mem_uninitialized_valid<T>() {
unreachable!()
}
/// Gets a reference to a static `Location` indicating where it was called. /// Gets a reference to a static `Location` indicating where it was called.
/// ///
@ -1090,9 +1102,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// Consider using [`core::panic::Location::caller`] instead. /// Consider using [`core::panic::Location::caller`] instead.
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_caller_location", since = "1.79.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_caller_location", since = "1.79.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn caller_location() -> &'static crate::panic::Location<'static>; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn caller_location() -> &'static crate::panic::Location<'static> {
unreachable!()
}
/// Moves a value out of scope without running drop glue. /// Moves a value out of scope without running drop glue.
/// ///
@ -1105,9 +1120,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// any safety invariants. /// any safety invariants.
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_intrinsic_forget", since = "1.83.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_intrinsic_forget", since = "1.83.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn forget<T: ?Sized>(_: T); #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn forget<T: ?Sized>(_: T) {
unreachable!()
}
/// Reinterprets the bits of a value of one type as another type. /// Reinterprets the bits of a value of one type as another type.
/// ///
@ -1399,7 +1417,11 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
#[rustc_const_stable(feature = "const_transmute", since = "1.56.0")] #[rustc_const_stable(feature = "const_transmute", since = "1.56.0")]
#[rustc_diagnostic_item = "transmute"] #[rustc_diagnostic_item = "transmute"]
#[rustc_nounwind] #[rustc_nounwind]
pub fn transmute<Src, Dst>(src: Src) -> Dst; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn transmute<Src, Dst>(_src: Src) -> Dst {
unreachable!()
}
/// Like [`transmute`], but even less checked at compile-time: rather than /// Like [`transmute`], but even less checked at compile-time: rather than
/// giving an error for `size_of::<Src>() != size_of::<Dst>()`, it's /// giving an error for `size_of::<Src>() != size_of::<Dst>()`, it's
@ -1413,7 +1435,11 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_transmute", since = "1.56.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_transmute", since = "1.56.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn transmute_unchecked<Src, Dst>(src: Src) -> Dst; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn transmute_unchecked<Src, Dst>(_src: Src) -> Dst {
unreachable!()
}
/// Returns `true` if the actual type given as `T` requires drop /// Returns `true` if the actual type given as `T` requires drop
/// glue; returns `false` if the actual type provided for `T` /// glue; returns `false` if the actual type provided for `T`
@ -1430,9 +1456,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// The stabilized version of this intrinsic is [`mem::needs_drop`](crate::mem::needs_drop). /// The stabilized version of this intrinsic is [`mem::needs_drop`](crate::mem::needs_drop).
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_needs_drop", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_needs_drop", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn needs_drop<T: ?Sized>() -> bool; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn needs_drop<T: ?Sized>() -> bool {
unreachable!()
}
/// Calculates the offset from a pointer. /// Calculates the offset from a pointer.
/// ///
@ -1454,7 +1483,11 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn offset<Ptr, Delta>(dst: Ptr, offset: Delta) -> Ptr; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn offset<Ptr, Delta>(_dst: Ptr, _offset: Delta) -> Ptr {
unreachable!()
}
/// Calculates the offset from a pointer, potentially wrapping. /// Calculates the offset from a pointer, potentially wrapping.
/// ///
@ -1473,8 +1506,13 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn arith_offset<T>(dst: *const T, offset: isize) -> *const T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn arith_offset<T>(_dst: *const T, _offset: isize) -> *const T {
unreachable!()
}
extern "rust-intrinsic" {
/// Masks out bits of the pointer according to a mask. /// Masks out bits of the pointer according to a mask.
/// ///
/// Note that, unlike most intrinsics, this is safe to call; /// Note that, unlike most intrinsics, this is safe to call;
@ -2143,6 +2181,7 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// Stabilized as [`f32::to_int_unchecked`] and [`f64::to_int_unchecked`]. /// Stabilized as [`f32::to_int_unchecked`] and [`f64::to_int_unchecked`].
#[rustc_nounwind] #[rustc_nounwind]
pub fn float_to_int_unchecked<Float: Copy, Int: Copy>(value: Float) -> Int; pub fn float_to_int_unchecked<Float: Copy, Int: Copy>(value: Float) -> Int;
}
/// Returns the number of bits set in an integer type `T` /// Returns the number of bits set in an integer type `T`
/// ///
@ -2156,9 +2195,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// [`u32::count_ones`] /// [`u32::count_ones`]
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ctpop", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ctpop", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn ctpop<T: Copy>(x: T) -> u32; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn ctpop<T: Copy>(_x: T) -> u32 {
unimplemented!()
}
/// Returns the number of leading unset bits (zeroes) in an integer type `T`. /// Returns the number of leading unset bits (zeroes) in an integer type `T`.
/// ///
@ -2198,9 +2240,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// ``` /// ```
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ctlz", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ctlz", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn ctlz<T: Copy>(x: T) -> u32; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn ctlz<T: Copy>(_x: T) -> u32 {
unimplemented!()
}
/// Like `ctlz`, but extra-unsafe as it returns `undef` when /// Like `ctlz`, but extra-unsafe as it returns `undef` when
/// given an `x` with value `0`. /// given an `x` with value `0`.
@ -2222,7 +2267,11 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
#[cfg_attr(bootstrap, rustc_const_stable(feature = "constctlz", since = "1.50.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "constctlz", since = "1.50.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn ctlz_nonzero<T: Copy>(x: T) -> u32; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn ctlz_nonzero<T: Copy>(_x: T) -> u32 {
unimplemented!()
}
/// Returns the number of trailing unset bits (zeroes) in an integer type `T`. /// Returns the number of trailing unset bits (zeroes) in an integer type `T`.
/// ///
@ -2262,9 +2311,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// ``` /// ```
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_cttz", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_cttz", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn cttz<T: Copy>(x: T) -> u32; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn cttz<T: Copy>(_x: T) -> u32 {
unimplemented!()
}
/// Like `cttz`, but extra-unsafe as it returns `undef` when /// Like `cttz`, but extra-unsafe as it returns `undef` when
/// given an `x` with value `0`. /// given an `x` with value `0`.
@ -2286,7 +2338,11 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_cttz_nonzero", since = "1.53.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_cttz_nonzero", since = "1.53.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn cttz_nonzero<T: Copy>(x: T) -> u32; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn cttz_nonzero<T: Copy>(_x: T) -> u32 {
unimplemented!()
}
/// Reverses the bytes in an integer type `T`. /// Reverses the bytes in an integer type `T`.
/// ///
@ -2300,9 +2356,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// [`u32::swap_bytes`] /// [`u32::swap_bytes`]
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_bswap", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_bswap", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn bswap<T: Copy>(x: T) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn bswap<T: Copy>(_x: T) -> T {
unimplemented!()
}
/// Reverses the bits in an integer type `T`. /// Reverses the bits in an integer type `T`.
/// ///
@ -2316,9 +2375,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// [`u32::reverse_bits`] /// [`u32::reverse_bits`]
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_bitreverse", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_bitreverse", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn bitreverse<T: Copy>(x: T) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn bitreverse<T: Copy>(_x: T) -> T {
unimplemented!()
}
/// Does a three-way comparison between the two integer arguments. /// Does a three-way comparison between the two integer arguments.
/// ///
@ -2328,8 +2390,11 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// ///
/// The stabilized version of this intrinsic is [`Ord::cmp`]. /// The stabilized version of this intrinsic is [`Ord::cmp`].
#[rustc_const_unstable(feature = "const_three_way_compare", issue = "none")] #[rustc_const_unstable(feature = "const_three_way_compare", issue = "none")]
#[rustc_safe_intrinsic] #[rustc_intrinsic]
pub fn three_way_compare<T: Copy>(lhs: T, rhs: T) -> crate::cmp::Ordering; #[rustc_intrinsic_must_be_overridden]
pub const fn three_way_compare<T: Copy>(_lhs: T, _rhss: T) -> crate::cmp::Ordering {
unimplemented!()
}
/// Performs checked integer addition. /// Performs checked integer addition.
/// ///
@ -2343,9 +2408,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// [`u32::overflowing_add`] /// [`u32::overflowing_add`]
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_overflow", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_overflow", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn add_with_overflow<T: Copy>(x: T, y: T) -> (T, bool); #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn add_with_overflow<T: Copy>(_x: T, _y: T) -> (T, bool) {
unimplemented!()
}
/// Performs checked integer subtraction /// Performs checked integer subtraction
/// ///
@ -2359,9 +2427,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// [`u32::overflowing_sub`] /// [`u32::overflowing_sub`]
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_overflow", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_overflow", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn sub_with_overflow<T: Copy>(x: T, y: T) -> (T, bool); #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn sub_with_overflow<T: Copy>(_x: T, _y: T) -> (T, bool) {
unimplemented!()
}
/// Performs checked integer multiplication /// Performs checked integer multiplication
/// ///
@ -2375,9 +2446,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// [`u32::overflowing_mul`] /// [`u32::overflowing_mul`]
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_overflow", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_overflow", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn mul_with_overflow<T: Copy>(x: T, y: T) -> (T, bool); #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn mul_with_overflow<T: Copy>(_x: T, _y: T) -> (T, bool) {
unimplemented!()
}
/// Performs an exact division, resulting in undefined behavior where /// Performs an exact division, resulting in undefined behavior where
/// `x % y != 0` or `y == 0` or `x == T::MIN && y == -1` /// `x % y != 0` or `y == 0` or `x == T::MIN && y == -1`
@ -2385,7 +2459,11 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// This intrinsic does not have a stable counterpart. /// This intrinsic does not have a stable counterpart.
#[rustc_const_unstable(feature = "const_exact_div", issue = "none")] #[rustc_const_unstable(feature = "const_exact_div", issue = "none")]
#[rustc_nounwind] #[rustc_nounwind]
pub fn exact_div<T: Copy>(x: T, y: T) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn exact_div<T: Copy>(_x: T, _y: T) -> T {
unimplemented!()
}
/// Performs an unchecked division, resulting in undefined behavior /// Performs an unchecked division, resulting in undefined behavior
/// where `y == 0` or `x == T::MIN && y == -1` /// where `y == 0` or `x == T::MIN && y == -1`
@ -2393,26 +2471,28 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// Safe wrappers for this intrinsic are available on the integer /// Safe wrappers for this intrinsic are available on the integer
/// primitives via the `checked_div` method. For example, /// primitives via the `checked_div` method. For example,
/// [`u32::checked_div`] /// [`u32::checked_div`]
#[cfg_attr( #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_unchecked_div", since = "1.52.0"))]
bootstrap,
rustc_const_stable(feature = "const_int_unchecked_div", since = "1.52.0")
)]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn unchecked_div<T: Copy>(x: T, y: T) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn unchecked_div<T: Copy>(_x: T, _y: T) -> T {
unimplemented!()
}
/// Returns the remainder of an unchecked division, resulting in /// Returns the remainder of an unchecked division, resulting in
/// undefined behavior when `y == 0` or `x == T::MIN && y == -1` /// undefined behavior when `y == 0` or `x == T::MIN && y == -1`
/// ///
/// Safe wrappers for this intrinsic are available on the integer /// Safe wrappers for this intrinsic are available on the integer
/// primitives via the `checked_rem` method. For example, /// primitives via the `checked_rem` method. For example,
/// [`u32::checked_rem`] /// [`u32::checked_rem`]
#[cfg_attr( #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_unchecked_rem", since = "1.52.0"))]
bootstrap,
rustc_const_stable(feature = "const_int_unchecked_rem", since = "1.52.0")
)]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn unchecked_rem<T: Copy>(x: T, y: T) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn unchecked_rem<T: Copy>(_x: T, _y: T) -> T {
unimplemented!()
}
/// Performs an unchecked left shift, resulting in undefined behavior when /// Performs an unchecked left shift, resulting in undefined behavior when
/// `y < 0` or `y >= N`, where N is the width of T in bits. /// `y < 0` or `y >= N`, where N is the width of T in bits.
@ -2423,7 +2503,11 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_unchecked", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_unchecked", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn unchecked_shl<T: Copy, U: Copy>(x: T, y: U) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn unchecked_shl<T: Copy, U: Copy>(_x: T, _y: U) -> T {
unimplemented!()
}
/// Performs an unchecked right shift, resulting in undefined behavior when /// Performs an unchecked right shift, resulting in undefined behavior when
/// `y < 0` or `y >= N`, where N is the width of T in bits. /// `y < 0` or `y >= N`, where N is the width of T in bits.
/// ///
@ -2433,7 +2517,11 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_unchecked", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_unchecked", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn unchecked_shr<T: Copy, U: Copy>(x: T, y: U) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn unchecked_shr<T: Copy, U: Copy>(_x: T, _y: U) -> T {
unimplemented!()
}
/// Returns the result of an unchecked addition, resulting in /// Returns the result of an unchecked addition, resulting in
/// undefined behavior when `x + y > T::MAX` or `x + y < T::MIN`. /// undefined behavior when `x + y > T::MAX` or `x + y < T::MIN`.
@ -2443,7 +2531,11 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
#[cfg_attr(bootstrap, rustc_const_stable(feature = "unchecked_math", since = "1.79.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "unchecked_math", since = "1.79.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn unchecked_add<T: Copy>(x: T, y: T) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn unchecked_add<T: Copy>(_x: T, _y: T) -> T {
unimplemented!()
}
/// Returns the result of an unchecked subtraction, resulting in /// Returns the result of an unchecked subtraction, resulting in
/// undefined behavior when `x - y > T::MAX` or `x - y < T::MIN`. /// undefined behavior when `x - y > T::MAX` or `x - y < T::MIN`.
@ -2453,7 +2545,11 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
#[cfg_attr(bootstrap, rustc_const_stable(feature = "unchecked_math", since = "1.79.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "unchecked_math", since = "1.79.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn unchecked_sub<T: Copy>(x: T, y: T) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn unchecked_sub<T: Copy>(_x: T, _y: T) -> T {
unimplemented!()
}
/// Returns the result of an unchecked multiplication, resulting in /// Returns the result of an unchecked multiplication, resulting in
/// undefined behavior when `x * y > T::MAX` or `x * y < T::MIN`. /// undefined behavior when `x * y > T::MAX` or `x * y < T::MIN`.
@ -2463,7 +2559,11 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
#[cfg_attr(bootstrap, rustc_const_stable(feature = "unchecked_math", since = "1.79.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "unchecked_math", since = "1.79.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn unchecked_mul<T: Copy>(x: T, y: T) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn unchecked_mul<T: Copy>(_x: T, _y: T) -> T {
unimplemented!()
}
/// Performs rotate left. /// Performs rotate left.
/// ///
@ -2477,9 +2577,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// [`u32::rotate_left`] /// [`u32::rotate_left`]
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_rotate", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_rotate", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn rotate_left<T: Copy>(x: T, shift: u32) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn rotate_left<T: Copy>(_x: T, _shift: u32) -> T {
unimplemented!()
}
/// Performs rotate right. /// Performs rotate right.
/// ///
@ -2493,9 +2596,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// [`u32::rotate_right`] /// [`u32::rotate_right`]
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_rotate", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_rotate", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn rotate_right<T: Copy>(x: T, shift: u32) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn rotate_right<T: Copy>(_x: T, _shift: u32) -> T {
unimplemented!()
}
/// Returns (a + b) mod 2<sup>N</sup>, where N is the width of T in bits. /// Returns (a + b) mod 2<sup>N</sup>, where N is the width of T in bits.
/// ///
@ -2509,9 +2615,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// [`u32::wrapping_add`] /// [`u32::wrapping_add`]
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn wrapping_add<T: Copy>(a: T, b: T) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn wrapping_add<T: Copy>(_a: T, _b: T) -> T {
unimplemented!()
}
/// Returns (a - b) mod 2<sup>N</sup>, where N is the width of T in bits. /// Returns (a - b) mod 2<sup>N</sup>, where N is the width of T in bits.
/// ///
/// Note that, unlike most intrinsics, this is safe to call; /// Note that, unlike most intrinsics, this is safe to call;
@ -2524,9 +2633,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// [`u32::wrapping_sub`] /// [`u32::wrapping_sub`]
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn wrapping_sub<T: Copy>(a: T, b: T) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn wrapping_sub<T: Copy>(_a: T, _b: T) -> T {
unimplemented!()
}
/// Returns (a * b) mod 2<sup>N</sup>, where N is the width of T in bits. /// Returns (a * b) mod 2<sup>N</sup>, where N is the width of T in bits.
/// ///
/// Note that, unlike most intrinsics, this is safe to call; /// Note that, unlike most intrinsics, this is safe to call;
@ -2539,9 +2651,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// [`u32::wrapping_mul`] /// [`u32::wrapping_mul`]
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn wrapping_mul<T: Copy>(a: T, b: T) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn wrapping_mul<T: Copy>(_a: T, _b: T) -> T {
unimplemented!()
}
/// Computes `a + b`, saturating at numeric bounds. /// Computes `a + b`, saturating at numeric bounds.
/// ///
@ -2555,9 +2670,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// [`u32::saturating_add`] /// [`u32::saturating_add`]
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_saturating", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_saturating", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn saturating_add<T: Copy>(a: T, b: T) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn saturating_add<T: Copy>(_a: T, _b: T) -> T {
unimplemented!()
}
/// Computes `a - b`, saturating at numeric bounds. /// Computes `a - b`, saturating at numeric bounds.
/// ///
/// Note that, unlike most intrinsics, this is safe to call; /// Note that, unlike most intrinsics, this is safe to call;
@ -2570,9 +2688,12 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// [`u32::saturating_sub`] /// [`u32::saturating_sub`]
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_saturating", since = "1.40.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_int_saturating", since = "1.40.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn saturating_sub<T: Copy>(a: T, b: T) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn saturating_sub<T: Copy>(_a: T, _b: T) -> T {
unimplemented!()
}
/// This is an implementation detail of [`crate::ptr::read`] and should /// This is an implementation detail of [`crate::ptr::read`] and should
/// not be used anywhere else. See its comments for why this exists. /// not be used anywhere else. See its comments for why this exists.
@ -2583,7 +2704,11 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_read", since = "1.71.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_read", since = "1.71.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn read_via_copy<T>(ptr: *const T) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn read_via_copy<T>(_ptr: *const T) -> T {
unimplemented!()
}
/// This is an implementation detail of [`crate::ptr::write`] and should /// This is an implementation detail of [`crate::ptr::write`] and should
/// not be used anywhere else. See its comments for why this exists. /// not be used anywhere else. See its comments for why this exists.
@ -2594,7 +2719,11 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_write", since = "1.83.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_write", since = "1.83.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn write_via_move<T>(ptr: *mut T, value: T); #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn write_via_move<T>(_ptr: *mut T, _value: T) {
unimplemented!()
}
/// Returns the value of the discriminant for the variant in 'v'; /// Returns the value of the discriminant for the variant in 'v';
/// if `T` has no discriminant, returns `0`. /// if `T` has no discriminant, returns `0`.
@ -2607,10 +2736,14 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// The stabilized version of this intrinsic is [`core::mem::discriminant`]. /// The stabilized version of this intrinsic is [`core::mem::discriminant`].
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_discriminant", since = "1.75.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_discriminant", since = "1.75.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn discriminant_value<T>(v: &T) -> <T as DiscriminantKind>::Discriminant; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn discriminant_value<T>(_v: &T) -> <T as DiscriminantKind>::Discriminant {
unimplemented!()
}
extern "rust-intrinsic" {
/// Rust's "try catch" construct for unwinding. Invokes the function pointer `try_fn` with the /// Rust's "try catch" construct for unwinding. Invokes the function pointer `try_fn` with the
/// data pointer `data`, and calls `catch_fn` if unwinding occurs while `try_fn` runs. /// data pointer `data`, and calls `catch_fn` if unwinding occurs while `try_fn` runs.
/// ///
@ -2638,17 +2771,25 @@ pub fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// in ways that are not allowed for regular writes). /// in ways that are not allowed for regular writes).
#[rustc_nounwind] #[rustc_nounwind]
pub fn nontemporal_store<T>(ptr: *mut T, val: T); pub fn nontemporal_store<T>(ptr: *mut T, val: T);
}
/// See documentation of `<*const T>::offset_from` for details. /// See documentation of `<*const T>::offset_from` for details.
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_offset_from", since = "1.65.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_offset_from", since = "1.65.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn ptr_offset_from<T>(ptr: *const T, base: *const T) -> isize; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn ptr_offset_from<T>(_ptr: *const T, _base: *const T) -> isize {
unimplemented!()
}
/// See documentation of `<*const T>::sub_ptr` for details. /// See documentation of `<*const T>::sub_ptr` for details.
#[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")]
#[rustc_nounwind] #[rustc_nounwind]
pub fn ptr_offset_from_unsigned<T>(ptr: *const T, base: *const T) -> usize; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn ptr_offset_from_unsigned<T>(_ptr: *const T, _base: *const T) -> usize {
unimplemented!()
} }
/// See documentation of `<*const T>::guaranteed_eq` for details. /// See documentation of `<*const T>::guaranteed_eq` for details.
@ -2666,7 +2807,6 @@ pub const fn ptr_guaranteed_cmp<T>(ptr: *const T, other: *const T) -> u8 {
(ptr == other) as u8 (ptr == other) as u8
} }
extern "rust-intrinsic" {
/// Determines whether the raw bytes of the two values are equal. /// Determines whether the raw bytes of the two values are equal.
/// ///
/// This is particularly handy for arrays, since it allows things like just /// This is particularly handy for arrays, since it allows things like just
@ -2692,7 +2832,11 @@ pub const fn ptr_guaranteed_cmp<T>(ptr: *const T, other: *const T) -> u8 {
/// which is UB if any of their inputs are `undef`.) /// which is UB if any of their inputs are `undef`.)
#[rustc_const_unstable(feature = "const_intrinsic_raw_eq", issue = "none")] #[rustc_const_unstable(feature = "const_intrinsic_raw_eq", issue = "none")]
#[rustc_nounwind] #[rustc_nounwind]
pub fn raw_eq<T>(a: &T, b: &T) -> bool; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn raw_eq<T>(_a: &T, _b: &T) -> bool {
unimplemented!()
}
/// Lexicographically compare `[left, left + bytes)` and `[right, right + bytes)` /// Lexicographically compare `[left, left + bytes)` and `[right, right + bytes)`
/// as unsigned bytes, returning negative if `left` is less, zero if all the /// as unsigned bytes, returning negative if `left` is less, zero if all the
@ -2710,15 +2854,21 @@ pub const fn ptr_guaranteed_cmp<T>(ptr: *const T, other: *const T) -> u8 {
/// [valid]: crate::ptr#safety /// [valid]: crate::ptr#safety
#[rustc_const_unstable(feature = "const_intrinsic_compare_bytes", issue = "none")] #[rustc_const_unstable(feature = "const_intrinsic_compare_bytes", issue = "none")]
#[rustc_nounwind] #[rustc_nounwind]
pub fn compare_bytes(left: *const u8, right: *const u8, bytes: usize) -> i32; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const unsafe fn compare_bytes(_left: *const u8, _right: *const u8, _bytes: usize) -> i32 {
unimplemented!()
}
/// See documentation of [`std::hint::black_box`] for details. /// See documentation of [`std::hint::black_box`] for details.
/// ///
/// [`std::hint::black_box`]: crate::hint::black_box /// [`std::hint::black_box`]: crate::hint::black_box
#[rustc_const_unstable(feature = "const_black_box", issue = "none")] #[rustc_const_unstable(feature = "const_black_box", issue = "none")]
#[rustc_safe_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub fn black_box<T>(dummy: T) -> T; #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub const fn black_box<T>(_dummy: T) -> T {
unimplemented!()
} }
/// Selects which function to call depending on the context. /// Selects which function to call depending on the context.
@ -3261,18 +3411,13 @@ pub const fn ptr_metadata<P: ptr::Pointee<Metadata = M> + ?Sized, M>(_ptr: *cons
#[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_diagnostic_item = "ptr_copy_nonoverlapping"] #[rustc_diagnostic_item = "ptr_copy_nonoverlapping"]
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" { #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0"))]
#[cfg_attr(
bootstrap,
rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0")
)]
#[cfg_attr(
not(bootstrap),
rustc_const_unstable(feature = "core_intrinsics", issue = "none")
)]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
pub fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize); #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
const unsafe fn copy_nonoverlapping<T>(_src: *const T, _dst: *mut T, _count: usize) {
unreachable!()
} }
ub_checks::assert_unsafe_precondition!( ub_checks::assert_unsafe_precondition!(
@ -3373,18 +3518,13 @@ pub const fn ptr_metadata<P: ptr::Pointee<Metadata = M> + ?Sized, M>(_ptr: *cons
#[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_diagnostic_item = "ptr_copy"] #[rustc_diagnostic_item = "ptr_copy"]
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" { #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0"))]
#[cfg_attr(
bootstrap,
rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0")
)]
#[cfg_attr(
not(bootstrap),
rustc_const_unstable(feature = "core_intrinsics", issue = "none")
)]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
fn copy<T>(src: *const T, dst: *mut T, count: usize); #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
const unsafe fn copy<T>(_src: *const T, _dst: *mut T, _count: usize) {
unreachable!()
} }
// SAFETY: the safety contract for `copy` must be upheld by the caller. // SAFETY: the safety contract for `copy` must be upheld by the caller.
@ -3462,11 +3602,13 @@ pub const fn ptr_metadata<P: ptr::Pointee<Metadata = M> + ?Sized, M>(_ptr: *cons
#[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_diagnostic_item = "ptr_write_bytes"] #[rustc_diagnostic_item = "ptr_write_bytes"]
pub const unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) { pub const unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
extern "rust-intrinsic" {
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_write", since = "1.83.0"))] #[cfg_attr(bootstrap, rustc_const_stable(feature = "const_ptr_write", since = "1.83.0"))]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)] #[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind] #[rustc_nounwind]
fn write_bytes<T>(dst: *mut T, val: u8, count: usize); #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
const unsafe fn write_bytes<T>(_dst: *mut T, _val: u8, _count: usize) {
unreachable!()
} }
// SAFETY: the safety contract for `write_bytes` must be upheld by the caller. // SAFETY: the safety contract for `write_bytes` must be upheld by the caller.