@@ -2525,15 +2525,30 @@ extern "rust-intrinsic" {
2525
2525
/// or `false`, and the caller has to ensure sound behavior for both cases.
2526
2526
/// In other words, the following code has *Undefined Behavior*:
2527
2527
///
2528
- /// ```rust
2529
- /// if !is_val_statically_known(0) { unreachable_unchecked(); }
2528
+ /// ```
2529
+ /// #![feature(is_val_statically_known)]
2530
+ /// #![feature(core_intrinsics)]
2531
+ /// # #![allow(internal_features)]
2532
+ /// use std::hint::unreachable_unchecked;
2533
+ /// use std::intrinsics::is_val_statically_known;
2534
+ ///
2535
+ /// unsafe {
2536
+ /// if !is_val_statically_known(0) { unreachable_unchecked(); }
2537
+ /// }
2530
2538
/// ```
2531
2539
///
2532
2540
/// This also means that the following code's behavior is unspecified; it
2533
2541
/// may panic, or it may not:
2534
2542
///
2535
- /// ```rust,no_run
2536
- /// assert_eq!(is_val_statically_known(0), black_box(is_val_statically_known(0)))
2543
+ /// ```no_run
2544
+ /// #![feature(is_val_statically_known)]
2545
+ /// #![feature(core_intrinsics)]
2546
+ /// # #![allow(internal_features)]
2547
+ /// use std::intrinsics::is_val_statically_known;
2548
+ ///
2549
+ /// unsafe {
2550
+ /// assert_eq!(is_val_statically_known(0), is_val_statically_known(0));
2551
+ /// }
2537
2552
/// ```
2538
2553
///
2539
2554
/// Unsafe code may not rely on `is_val_statically_known` returning any
@@ -2547,15 +2562,14 @@ extern "rust-intrinsic" {
2547
2562
#[ rustc_const_unstable( feature = "is_val_statically_known" , issue = "none" ) ]
2548
2563
#[ rustc_nounwind]
2549
2564
#[ cfg( not( bootstrap) ) ]
2550
- pub fn is_val_statically_known < T > ( arg : T ) -> bool ;
2565
+ pub fn is_val_statically_known < T : Copy > ( arg : T ) -> bool ;
2551
2566
}
2552
2567
2553
2568
// FIXME: Seems using `unstable` here completely ignores `rustc_allow_const_fn_unstable`
2554
2569
// and thus compiling stage0 core doesn't work.
2555
- #[ rustc_const_stable( feature = "is_val_statically_known" , since = "never " ) ]
2570
+ #[ rustc_const_stable( feature = "is_val_statically_known" , since = "0.0.0 " ) ]
2556
2571
#[ cfg( bootstrap) ]
2557
- pub const unsafe fn is_val_statically_known < T > ( t : T ) -> bool {
2558
- mem:: forget ( t) ;
2572
+ pub const unsafe fn is_val_statically_known < T : Copy > ( _arg : T ) -> bool {
2559
2573
false
2560
2574
}
2561
2575
0 commit comments