5555#![ allow( missing_docs) ]
5656
5757use crate :: ffi:: va_list:: { VaArgSafe , VaListImpl } ;
58- use crate :: marker:: { ConstParamTy , DiscriminantKind , PointeeSized , Tuple } ;
58+ use crate :: marker:: { ConstParamTy , Destruct , DiscriminantKind , PointeeSized , Tuple } ;
5959use crate :: ptr;
6060
6161mod bounds;
@@ -477,11 +477,15 @@ pub const fn unlikely(b: bool) -> bool {
477477/// However unlike the public form, the intrinsic will not drop the value that
478478/// is not selected.
479479#[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
480+ #[ rustc_const_unstable( feature = "const_select_unpredictable" , issue = "145938" ) ]
480481#[ rustc_intrinsic]
481482#[ rustc_nounwind]
482483#[ miri:: intrinsic_fallback_is_spec]
483484#[ inline]
484- pub fn select_unpredictable < T > ( b : bool , true_val : T , false_val : T ) -> T {
485+ pub const fn select_unpredictable < T > ( b : bool , true_val : T , false_val : T ) -> T
486+ where
487+ T : [ const ] Destruct ,
488+ {
485489 if b { true_val } else { false_val }
486490}
487491
@@ -2728,6 +2732,11 @@ pub unsafe fn vtable_align(ptr: *const ()) -> usize;
27282732/// More specifically, this is the offset in bytes between successive
27292733/// items of the same type, including alignment padding.
27302734///
2735+ /// Note that, unlike most intrinsics, this can only be called at compile-time
2736+ /// as backends do not have an implementation for it. The only caller (its
2737+ /// stable counterpart) wraps this intrinsic call in a `const` block so that
2738+ /// backends only see an evaluated constant.
2739+ ///
27312740/// The stabilized version of this intrinsic is [`core::mem::size_of`].
27322741#[ rustc_nounwind]
27332742#[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
@@ -2742,6 +2751,11 @@ pub const fn size_of<T>() -> usize;
27422751/// Therefore, implementations must not require the user to uphold
27432752/// any safety invariants.
27442753///
2754+ /// Note that, unlike most intrinsics, this can only be called at compile-time
2755+ /// as backends do not have an implementation for it. The only caller (its
2756+ /// stable counterpart) wraps this intrinsic call in a `const` block so that
2757+ /// backends only see an evaluated constant.
2758+ ///
27452759/// The stabilized version of this intrinsic is [`core::mem::align_of`].
27462760#[ rustc_nounwind]
27472761#[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
0 commit comments