@@ -2517,79 +2517,79 @@ extern "rust-intrinsic" {
2517
2517
where
2518
2518
G : FnOnce < ARG , Output = RET > ,
2519
2519
F : FnOnce < ARG , Output = RET > ;
2520
+ }
2520
2521
2521
- /// Returns whether the argument's value is statically known at
2522
- /// compile-time.
2523
- ///
2524
- /// This is useful when there is a way of writing the code that will
2525
- /// be *faster* when some variables have known values, but *slower*
2526
- /// in the general case: an `if is_val_statically_known(var)` can be used
2527
- /// to select between these two variants. The `if` will be optimized away
2528
- /// and only the desired branch remains.
2529
- ///
2530
- /// Formally speaking, this function non-deterministically returns `true`
2531
- /// or `false`, and the caller has to ensure sound behavior for both cases.
2532
- /// In other words, the following code has *Undefined Behavior*:
2533
- ///
2534
- /// ```no_run
2535
- /// #![feature(is_val_statically_known)]
2536
- /// #![feature(core_intrinsics)]
2537
- /// # #![allow(internal_features)]
2538
- /// use std::hint::unreachable_unchecked;
2539
- /// use std::intrinsics::is_val_statically_known;
2540
- ///
2541
- /// unsafe {
2542
- /// if !is_val_statically_known(0) { unreachable_unchecked(); }
2543
- /// }
2544
- /// ```
2545
- ///
2546
- /// This also means that the following code's behavior is unspecified; it
2547
- /// may panic, or it may not:
2548
- ///
2549
- /// ```no_run
2550
- /// #![feature(is_val_statically_known)]
2551
- /// #![feature(core_intrinsics)]
2552
- /// # #![allow(internal_features)]
2553
- /// use std::intrinsics::is_val_statically_known;
2554
- ///
2555
- /// unsafe {
2556
- /// assert_eq!(is_val_statically_known(0), is_val_statically_known(0));
2557
- /// }
2558
- /// ```
2559
- ///
2560
- /// Unsafe code may not rely on `is_val_statically_known` returning any
2561
- /// particular value, ever. However, the compiler will generally make it
2562
- /// return `true` only if the value of the argument is actually known.
2563
- ///
2564
- /// When calling this in a `const fn`, both paths must be semantically
2565
- /// equivalent, that is, the result of the `true` branch and the `false`
2566
- /// branch must return the same value and have the same side-effects *no
2567
- /// matter what*.
2568
- #[ rustc_const_unstable( feature = "is_val_statically_known" , issue = "none" ) ]
2569
- #[ rustc_nounwind]
2570
- pub fn is_val_statically_known < T : Copy > ( arg : T ) -> bool ;
2571
-
2572
- /// Returns the value of `cfg!(debug_assertions)`, but after monomorphization instead of in
2573
- /// macro expansion.
2574
- ///
2575
- /// This always returns `false` in const eval and Miri. The interpreter provides better
2576
- /// diagnostics than the checks that this is used to implement. However, this means
2577
- /// you should only be using this intrinsic to guard requirements that, if violated,
2578
- /// immediately lead to UB. Otherwise, const-eval and Miri will miss out on those
2579
- /// checks entirely.
2580
- ///
2581
- /// Since this is evaluated after monomorphization, branching on this value can be used to
2582
- /// implement debug assertions that are included in the precompiled standard library, but can
2583
- /// be optimized out by builds that monomorphize the standard library code with debug
2584
- /// assertions disabled. This intrinsic is primarily used by [`assert_unsafe_precondition`].
2585
- #[ rustc_const_unstable( feature = "delayed_debug_assertions" , issue = "none" ) ]
2586
- #[ rustc_safe_intrinsic]
2587
- #[ cfg( not( bootstrap) ) ]
2588
- pub ( crate ) fn debug_assertions ( ) -> bool ;
2522
+ /// Returns whether the argument's value is statically known at
2523
+ /// compile-time.
2524
+ ///
2525
+ /// This is useful when there is a way of writing the code that will
2526
+ /// be *faster* when some variables have known values, but *slower*
2527
+ /// in the general case: an `if is_val_statically_known(var)` can be used
2528
+ /// to select between these two variants. The `if` will be optimized away
2529
+ /// and only the desired branch remains.
2530
+ ///
2531
+ /// Formally speaking, this function non-deterministically returns `true`
2532
+ /// or `false`, and the caller has to ensure sound behavior for both cases.
2533
+ /// In other words, the following code has *Undefined Behavior*:
2534
+ ///
2535
+ /// ```no_run
2536
+ /// #![feature(is_val_statically_known)]
2537
+ /// #![feature(core_intrinsics)]
2538
+ /// # #![allow(internal_features)]
2539
+ /// use std::hint::unreachable_unchecked;
2540
+ /// use std::intrinsics::is_val_statically_known;
2541
+ ///
2542
+ /// unsafe {
2543
+ /// if !is_val_statically_known(0) { unreachable_unchecked(); }
2544
+ /// }
2545
+ /// ```
2546
+ ///
2547
+ /// This also means that the following code's behavior is unspecified; it
2548
+ /// may panic, or it may not:
2549
+ ///
2550
+ /// ```no_run
2551
+ /// #![feature(is_val_statically_known)]
2552
+ /// #![feature(core_intrinsics)]
2553
+ /// # #![allow(internal_features)]
2554
+ /// use std::intrinsics::is_val_statically_known;
2555
+ ///
2556
+ /// unsafe {
2557
+ /// assert_eq!(is_val_statically_known(0), is_val_statically_known(0));
2558
+ /// }
2559
+ /// ```
2560
+ ///
2561
+ /// Unsafe code may not rely on `is_val_statically_known` returning any
2562
+ /// particular value, ever. However, the compiler will generally make it
2563
+ /// return `true` only if the value of the argument is actually known.
2564
+ ///
2565
+ /// When calling this in a `const fn`, both paths must be semantically
2566
+ /// equivalent, that is, the result of the `true` branch and the `false`
2567
+ /// branch must return the same value and have the same side-effects *no
2568
+ /// matter what*.
2569
+ #[ rustc_const_unstable( feature = "is_val_statically_known" , issue = "none" ) ]
2570
+ #[ rustc_nounwind]
2571
+ #[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
2572
+ #[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
2573
+ pub const unsafe fn is_val_statically_known < T : Copy > ( _arg : T ) -> bool {
2574
+ false
2589
2575
}
2590
2576
2591
- #[ cfg( bootstrap) ]
2577
+ /// Returns the value of `cfg!(debug_assertions)`, but after monomorphization instead of in
2578
+ /// macro expansion.
2579
+ ///
2580
+ /// This always returns `false` in const eval and Miri. The interpreter provides better
2581
+ /// diagnostics than the checks that this is used to implement. However, this means
2582
+ /// you should only be using this intrinsic to guard requirements that, if violated,
2583
+ /// immediately lead to UB. Otherwise, const-eval and Miri will miss out on those
2584
+ /// checks entirely.
2585
+ ///
2586
+ /// Since this is evaluated after monomorphization, branching on this value can be used to
2587
+ /// implement debug assertions that are included in the precompiled standard library, but can
2588
+ /// be optimized out by builds that monomorphize the standard library code with debug
2589
+ /// assertions disabled. This intrinsic is primarily used by [`assert_unsafe_precondition`].
2592
2590
#[ rustc_const_unstable( feature = "delayed_debug_assertions" , issue = "none" ) ]
2591
+ #[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
2592
+ #[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
2593
2593
pub ( crate ) const fn debug_assertions ( ) -> bool {
2594
2594
cfg ! ( debug_assertions)
2595
2595
}
0 commit comments