@@ -3956,12 +3956,39 @@ pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
3956
3956
// Const-unstable because `swap_nonoverlapping` is const-unstable.
3957
3957
#[ rustc_intrinsic_const_stable_indirect]
3958
3958
#[ rustc_allow_const_fn_unstable( const_swap_nonoverlapping) ] // this is anyway not called since CTFE implements the intrinsic
3959
+ #[ cfg( bootstrap) ]
3959
3960
pub const unsafe fn typed_swap < T > ( x : * mut T , y : * mut T ) {
3960
3961
// SAFETY: The caller provided single non-overlapping items behind
3961
3962
// pointers, so swapping them with `count: 1` is fine.
3962
3963
unsafe { ptr:: swap_nonoverlapping ( x, y, 1 ) } ;
3963
3964
}
3964
3965
3966
+ #[ cfg( bootstrap) ]
3967
+ pub use typed_swap as typed_swap_nonoverlapping;
3968
+
3969
+ /// Non-overlapping *typed* swap of a single value.
3970
+ ///
3971
+ /// The codegen backends will replace this with a better implementation when
3972
+ /// `T` is a simple type that can be loaded and stored as an immediate.
3973
+ ///
3974
+ /// The stabilized form of this intrinsic is [`crate::mem::swap`].
3975
+ ///
3976
+ /// # Safety
3977
+ ///
3978
+ /// `x` and `y` are readable and writable as `T`, and non-overlapping.
3979
+ #[ rustc_nounwind]
3980
+ #[ inline]
3981
+ #[ rustc_intrinsic]
3982
+ // Const-unstable because `swap_nonoverlapping` is const-unstable.
3983
+ #[ rustc_intrinsic_const_stable_indirect]
3984
+ #[ rustc_allow_const_fn_unstable( const_swap_nonoverlapping) ] // this is anyway not called since CTFE implements the intrinsic
3985
+ #[ cfg( not( bootstrap) ) ]
3986
+ pub const unsafe fn typed_swap_nonoverlapping < T > ( x : * mut T , y : * mut T ) {
3987
+ // SAFETY: The caller provided single non-overlapping items behind
3988
+ // pointers, so swapping them with `count: 1` is fine.
3989
+ unsafe { ptr:: swap_nonoverlapping ( x, y, 1 ) } ;
3990
+ }
3991
+
3965
3992
/// Returns whether we should perform some UB-checking at runtime. This eventually evaluates to
3966
3993
/// `cfg!(ub_checks)`, but behaves different from `cfg!` when mixing crates built with different
3967
3994
/// flags: if the crate has UB checks enabled or carries the `#[rustc_preserve_ub_checks]`
0 commit comments