@@ -955,43 +955,50 @@ extern "rust-intrinsic" {
955955#[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
956956pub const unsafe fn assume ( b : bool ) {
957957 if !b {
958+ // SAFETY: the caller must guarantee the argument is never `false`
958959 unsafe { unreachable ( ) }
959960 }
960961}
961962
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+ }
978981
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+ }
9941000
1001+ extern "rust-intrinsic" {
9951002 /// Executes a breakpoint trap, for inspection by a debugger.
9961003 ///
9971004 /// This intrinsic does not have a stable counterpart.
@@ -1074,33 +1081,38 @@ extern "rust-intrinsic" {
10741081 #[ rustc_safe_intrinsic]
10751082 #[ rustc_nounwind]
10761083 pub fn type_id < T : ?Sized + ' static > ( ) -> u128 ;
1084+ }
10771085
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 > ( ) { }
10861095
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 > ( ) { }
10951105
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 > ( ) { }
11031114
1115+ extern "rust-intrinsic" {
11041116 /// Gets a reference to a static `Location` indicating where it was called.
11051117 ///
11061118 /// Note that, unlike most intrinsics, this is safe to call;
0 commit comments