@@ -2717,10 +2717,45 @@ where
2717
2717
/// particular value, ever. However, the compiler will generally make it
2718
2718
/// return `true` only if the value of the argument is actually known.
2719
2719
///
2720
- /// When calling this in a `const fn`, both paths must be semantically
2721
- /// equivalent, that is, the result of the `true` branch and the `false`
2722
- /// branch must return the same value and have the same side-effects *no
2723
- /// matter what*.
2720
+ /// # Stability concerns
2721
+ ///
2722
+ /// While it is safe to call, this intrinsic may behave differently in
2723
+ /// a `const` context than otherwise. See the [`const_eval_select`]
2724
+ /// documentation for an explanation of the issues this can cause. Unlike
2725
+ /// `const_eval_select`, this intrinsic isn't guaranteed to behave
2726
+ /// deterministically even in a `const` context.
2727
+ ///
2728
+ /// # Type Requirements
2729
+ ///
2730
+ /// `T` must be either a `bool`, a `char`, a primitive numeric type (e.g. `f32`,
2731
+ /// but not `NonZeroISize`), or any thin pointer (e.g. `*mut String`).
2732
+ /// Any other argument types *may* cause a compiler error.
2733
+ ///
2734
+ /// ## Pointers
2735
+ ///
2736
+ /// When the input is a pointer, only the pointer itself is
2737
+ /// ever considered. The pointee has no effect. Currently, these functions
2738
+ /// behave identically:
2739
+ ///
2740
+ /// ```
2741
+ /// #![feature(is_val_statically_known)]
2742
+ /// #![feature(core_intrinsics)]
2743
+ /// # #![allow(internal_features)]
2744
+ /// #![feature(strict_provenance)]
2745
+ /// use std::intrinsics::is_val_statically_known;
2746
+ ///
2747
+ /// fn foo(x: &i32) -> bool {
2748
+ /// is_val_statically_known(x)
2749
+ /// }
2750
+ ///
2751
+ /// fn bar(x: &i32) -> bool {
2752
+ /// is_val_statically_known(
2753
+ /// (x as *const i32).addr()
2754
+ /// )
2755
+ /// }
2756
+ /// # _ = foo(&5_i32);
2757
+ /// # _ = bar(&5_i32);
2758
+ /// ```
2724
2759
#[ rustc_const_unstable( feature = "is_val_statically_known" , issue = "none" ) ]
2725
2760
#[ rustc_nounwind]
2726
2761
#[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
0 commit comments