@@ -937,20 +937,30 @@ extern "rust-intrinsic" {
937
937
#[ rustc_nounwind]
938
938
pub fn unreachable ( ) -> !;
939
939
940
- /// Informs the optimizer that a condition is always true.
941
- /// If the condition is false, the behavior is undefined.
942
- ///
943
- /// No code is generated for this intrinsic, but the optimizer will try
944
- /// to preserve it (and its condition) between passes, which may interfere
945
- /// with optimization of surrounding code and reduce performance. It should
946
- /// not be used if the invariant can be discovered by the optimizer on its
947
- /// own, or if it does not enable any significant optimizations.
948
- ///
949
- /// This intrinsic does not have a stable counterpart.
950
- #[ rustc_const_stable( feature = "const_assume" , since = "1.77.0" ) ]
951
- #[ rustc_nounwind]
952
- pub fn assume ( b : bool ) ;
940
+ }
941
+
942
+ /// Informs the optimizer that a condition is always true.
943
+ /// If the condition is false, the behavior is undefined.
944
+ ///
945
+ /// No code is generated for this intrinsic, but the optimizer will try
946
+ /// to preserve it (and its condition) between passes, which may interfere
947
+ /// with optimization of surrounding code and reduce performance. It should
948
+ /// not be used if the invariant can be discovered by the optimizer on its
949
+ /// own, or if it does not enable any significant optimizations.
950
+ ///
951
+ /// This intrinsic does not have a stable counterpart.
952
+ #[ rustc_const_stable( feature = "const_assume" , since = "1.77.0" ) ]
953
+ #[ rustc_nounwind]
954
+ #[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
955
+ #[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
956
+ pub const unsafe fn assume ( b : bool ) {
957
+ if !b {
958
+ // SAFETY: the caller must guarantee the argument is never `false`
959
+ unsafe { unreachable ( ) }
960
+ }
961
+ }
953
962
963
+ extern "rust-intrinsic" {
954
964
/// Hints to the compiler that branch condition is likely to be true.
955
965
/// Returns the value passed to it.
956
966
///
0 commit comments