Skip to content

Commit 98c8eaa

Browse files
committed
Support safe intrinsics with fallback bodies
Turn `is_val_statically_known` into such an intrinsic to demonstrate. It is perfectly safe to call after all.
1 parent ff787b4 commit 98c8eaa

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

core/src/intrinsics.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2513,9 +2513,7 @@ extern "rust-intrinsic" {
25132513
/// use std::hint::unreachable_unchecked;
25142514
/// use std::intrinsics::is_val_statically_known;
25152515
///
2516-
/// unsafe {
2517-
/// if !is_val_statically_known(0) { unreachable_unchecked(); }
2518-
/// }
2516+
/// if !is_val_statically_known(0) { unsafe { unreachable_unchecked(); } }
25192517
/// ```
25202518
///
25212519
/// This also means that the following code's behavior is unspecified; it
@@ -2527,9 +2525,7 @@ extern "rust-intrinsic" {
25272525
/// # #![allow(internal_features)]
25282526
/// use std::intrinsics::is_val_statically_known;
25292527
///
2530-
/// unsafe {
2531-
/// assert_eq!(is_val_statically_known(0), is_val_statically_known(0));
2532-
/// }
2528+
/// assert_eq!(is_val_statically_known(0), is_val_statically_known(0));
25332529
/// ```
25342530
///
25352531
/// Unsafe code may not rely on `is_val_statically_known` returning any
@@ -2544,7 +2540,7 @@ extern "rust-intrinsic" {
25442540
#[rustc_nounwind]
25452541
#[unstable(feature = "core_intrinsics", issue = "none")]
25462542
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
2547-
pub const unsafe fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
2543+
pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
25482544
false
25492545
}
25502546

@@ -2564,7 +2560,7 @@ pub const unsafe fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
25642560
#[rustc_const_unstable(feature = "delayed_debug_assertions", issue = "none")]
25652561
#[unstable(feature = "core_intrinsics", issue = "none")]
25662562
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
2567-
pub(crate) const unsafe fn debug_assertions() -> bool {
2563+
pub(crate) const fn debug_assertions() -> bool {
25682564
cfg!(debug_assertions)
25692565
}
25702566

0 commit comments

Comments
 (0)