@@ -3956,12 +3956,39 @@ pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
39563956// Const-unstable because `swap_nonoverlapping` is const-unstable.
39573957#[ rustc_intrinsic_const_stable_indirect]
39583958#[ rustc_allow_const_fn_unstable( const_swap_nonoverlapping) ] // this is anyway not called since CTFE implements the intrinsic
3959+ #[ cfg( bootstrap) ]
39593960pub const unsafe fn typed_swap < T > ( x : * mut T , y : * mut T ) {
39603961 // SAFETY: The caller provided single non-overlapping items behind
39613962 // pointers, so swapping them with `count: 1` is fine.
39623963 unsafe { ptr:: swap_nonoverlapping ( x, y, 1 ) } ;
39633964}
39643965
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+
39653992/// Returns whether we should perform some UB-checking at runtime. This eventually evaluates to
39663993/// `cfg!(ub_checks)`, but behaves different from `cfg!` when mixing crates built with different
39673994/// flags: if the crate has UB checks enabled or carries the `#[rustc_preserve_ub_checks]`
0 commit comments