@@ -955,43 +955,50 @@ extern "rust-intrinsic" {
955
955
#[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
956
956
pub const unsafe fn assume ( b : bool ) {
957
957
if !b {
958
+ // SAFETY: the caller must guarantee the argument is never `false`
958
959
unsafe { unreachable ( ) }
959
960
}
960
961
}
961
962
962
- extern "rust-intrinsic" {
963
- /// Hints to the compiler that branch condition is likely to be true.
964
- /// Returns the value passed to it.
965
- ///
966
- /// Any use other than with `if` statements will probably not have an effect.
967
- ///
968
- /// Note that, unlike most intrinsics, this is safe to call;
969
- /// it does not require an `unsafe` block.
970
- /// Therefore, implementations must not require the user to uphold
971
- /// any safety invariants.
972
- ///
973
- /// This intrinsic does not have a stable counterpart.
974
- #[ rustc_const_unstable( feature = "const_likely" , issue = "none" ) ]
975
- #[ rustc_safe_intrinsic]
976
- #[ rustc_nounwind]
977
- pub fn likely ( b : bool ) -> bool ;
963
+ /// Hints to the compiler that branch condition is likely to be true.
964
+ /// Returns the value passed to it.
965
+ ///
966
+ /// Any use other than with `if` statements will probably not have an effect.
967
+ ///
968
+ /// Note that, unlike most intrinsics, this is safe to call;
969
+ /// it does not require an `unsafe` block.
970
+ /// Therefore, implementations must not require the user to uphold
971
+ /// any safety invariants.
972
+ ///
973
+ /// This intrinsic does not have a stable counterpart.
974
+ #[ rustc_const_unstable( feature = "const_likely" , issue = "none" ) ]
975
+ #[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
976
+ #[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
977
+ #[ rustc_nounwind]
978
+ pub const fn likely ( b : bool ) -> bool {
979
+ b
980
+ }
978
981
979
- /// Hints to the compiler that branch condition is likely to be false.
980
- /// Returns the value passed to it.
981
- ///
982
- /// Any use other than with `if` statements will probably not have an effect.
983
- ///
984
- /// Note that, unlike most intrinsics, this is safe to call;
985
- /// it does not require an `unsafe` block.
986
- /// Therefore, implementations must not require the user to uphold
987
- /// any safety invariants.
988
- ///
989
- /// This intrinsic does not have a stable counterpart.
990
- #[ rustc_const_unstable( feature = "const_likely" , issue = "none" ) ]
991
- #[ rustc_safe_intrinsic]
992
- #[ rustc_nounwind]
993
- pub fn unlikely ( b : bool ) -> bool ;
982
+ /// Hints to the compiler that branch condition is likely to be false.
983
+ /// Returns the value passed to it.
984
+ ///
985
+ /// Any use other than with `if` statements will probably not have an effect.
986
+ ///
987
+ /// Note that, unlike most intrinsics, this is safe to call;
988
+ /// it does not require an `unsafe` block.
989
+ /// Therefore, implementations must not require the user to uphold
990
+ /// any safety invariants.
991
+ ///
992
+ /// This intrinsic does not have a stable counterpart.
993
+ #[ rustc_const_unstable( feature = "const_likely" , issue = "none" ) ]
994
+ #[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
995
+ #[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
996
+ #[ rustc_nounwind]
997
+ pub const fn unlikely ( b : bool ) -> bool {
998
+ b
999
+ }
994
1000
1001
+ extern "rust-intrinsic" {
995
1002
/// Executes a breakpoint trap, for inspection by a debugger.
996
1003
///
997
1004
/// This intrinsic does not have a stable counterpart.
@@ -1074,33 +1081,38 @@ extern "rust-intrinsic" {
1074
1081
#[ rustc_safe_intrinsic]
1075
1082
#[ rustc_nounwind]
1076
1083
pub fn type_id < T : ?Sized + ' static > ( ) -> u128 ;
1084
+ }
1077
1085
1078
- /// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited:
1079
- /// This will statically either panic, or do nothing.
1080
- ///
1081
- /// This intrinsic does not have a stable counterpart.
1082
- #[ rustc_const_stable( feature = "const_assert_type" , since = "1.59.0" ) ]
1083
- #[ rustc_safe_intrinsic]
1084
- #[ rustc_nounwind]
1085
- pub fn assert_inhabited < T > ( ) ;
1086
+ /// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited:
1087
+ /// This will statically either panic, or do nothing.
1088
+ ///
1089
+ /// This intrinsic does not have a stable counterpart.
1090
+ #[ rustc_const_stable( feature = "const_assert_type" , since = "1.59.0" ) ]
1091
+ #[ rustc_nounwind]
1092
+ #[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
1093
+ #[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
1094
+ pub const fn assert_inhabited < T > ( ) { }
1086
1095
1087
- /// A guard for unsafe functions that cannot ever be executed if `T` does not permit
1088
- /// zero-initialization: This will statically either panic, or do nothing.
1089
- ///
1090
- /// This intrinsic does not have a stable counterpart.
1091
- #[ rustc_const_stable( feature = "const_assert_type2" , since = "1.75.0" ) ]
1092
- #[ rustc_safe_intrinsic]
1093
- #[ rustc_nounwind]
1094
- pub fn assert_zero_valid < T > ( ) ;
1096
+ /// A guard for unsafe functions that cannot ever be executed if `T` does not permit
1097
+ /// zero-initialization: This will statically either panic, or do nothing.
1098
+ ///
1099
+ /// This intrinsic does not have a stable counterpart.
1100
+ #[ rustc_const_stable( feature = "const_assert_type2" , since = "1.75.0" ) ]
1101
+ #[ rustc_nounwind]
1102
+ #[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
1103
+ #[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
1104
+ pub const fn assert_zero_valid < T > ( ) { }
1095
1105
1096
- /// A guard for `std::mem::uninitialized`. This will statically either panic, or do nothing.
1097
- ///
1098
- /// This intrinsic does not have a stable counterpart.
1099
- #[ rustc_const_stable( feature = "const_assert_type2" , since = "1.75.0" ) ]
1100
- #[ rustc_safe_intrinsic]
1101
- #[ rustc_nounwind]
1102
- pub fn assert_mem_uninitialized_valid < T > ( ) ;
1106
+ /// A guard for `std::mem::uninitialized`. This will statically either panic, or do nothing.
1107
+ ///
1108
+ /// This intrinsic does not have a stable counterpart.
1109
+ #[ rustc_const_stable( feature = "const_assert_type2" , since = "1.75.0" ) ]
1110
+ #[ rustc_nounwind]
1111
+ #[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
1112
+ #[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
1113
+ pub const fn assert_mem_uninitialized_valid < T > ( ) { }
1103
1114
1115
+ extern "rust-intrinsic" {
1104
1116
/// Gets a reference to a static `Location` indicating where it was called.
1105
1117
///
1106
1118
/// Note that, unlike most intrinsics, this is safe to call;
0 commit comments