@@ -2512,11 +2512,12 @@ extern "rust-intrinsic" {
25122512 G : FnOnce < ARG , Output = RET > ,
25132513 F : FnOnce < ARG , Output = RET > ;
25142514
2515- /// Returns whether the argument is known at compile-time.
2515+ /// Returns whether the argument's value is statically known at
2516+ /// compile-time.
25162517 ///
25172518 /// This is useful when there is a way of writing the code that will
25182519 /// be *faster* when some variables have known values, but *slower*
2519- /// in the general case: an `if is_compile_time_known (var)` can be used
2520+ /// in the general case: an `if is_val_statically_known (var)` can be used
25202521 /// to select between these two variants. The `if` will be optimized away
25212522 /// and only the desired branch remains.
25222523 ///
@@ -2525,16 +2526,35 @@ extern "rust-intrinsic" {
25252526 /// In other words, the following code has *Undefined Behavior*:
25262527 ///
25272528 /// ```rust
2528- /// if !is_compile_time_known (0) { unreachable_unchecked(); }
2529+ /// if !is_val_statically_known (0) { unreachable_unchecked(); }
25292530 /// ```
25302531 ///
2531- /// Unsafe code may not rely on `is_compile_time_known` returning any
2532+ /// This also means that the following code's behavior is unspecified; it
2533+ /// may panic, or it may not:
2534+ ///
2535+ /// ```rust,no_run
2536+ /// assert_eq!(is_val_statically_known(0), black_box(is_val_statically_known(0)))
2537+ /// ```
2538+ ///
2539+ /// Unsafe code may not rely on `is_val_statically_known` returning any
25322540 /// particular value, ever. However, the compiler will generally make it
25332541 /// return `true` only if the value of the argument is actually known.
2534- #[ rustc_const_unstable( feature = "is_compile_time_known" , issue = "none" ) ]
2542+ ///
2543+ /// When calling this in a `const fn`, both paths must be semantically
2544+ /// equivalent, that is, the result of the `true` branch and the `false`
2545+ /// branch return the same value *no matter what*.
2546+ #[ rustc_const_unstable( feature = "is_val_statically_known" , issue = "none" ) ]
25352547 #[ rustc_nounwind]
25362548 #[ cfg( not( bootstrap) ) ]
2537- pub fn is_compile_time_known < T > ( arg : T ) -> bool ;
2549+ pub fn is_val_statically_known < T > ( arg : * const T ) -> bool ;
2550+ }
2551+
2552+ // FIXME: Seems using `unstable` here completely ignores `rustc_allow_const_fn_unstable`
2553+ // and thus compiling stage0 core doesn't work.
2554+ #[ rustc_const_stable( feature = "is_val_statically_known" , since = "never" ) ]
2555+ #[ cfg( bootstrap) ]
2556+ pub const unsafe fn is_val_statically_known < T > ( _: * const T ) -> bool {
2557+ false
25382558}
25392559
25402560// Some functions are defined here because they accidentally got made
0 commit comments