@@ -712,6 +712,11 @@ extern "rust-intrinsic" {
712
712
713
713
/// Aborts the execution of the process.
714
714
///
715
+ /// Note that, unlike most intrinsics, this is safe to call;
716
+ /// it does not require an `unsafe` block.
717
+ /// Therefore, implementations must not require the user to uphold
718
+ /// any safety invariants.
719
+ ///
715
720
/// A more user-friendly and stable version of this operation is
716
721
/// [`std::process::abort`](../../std/process/fn.abort.html).
717
722
pub fn abort ( ) -> !;
@@ -745,6 +750,11 @@ extern "rust-intrinsic" {
745
750
///
746
751
/// Any use other than with `if` statements will probably not have an effect.
747
752
///
753
+ /// Note that, unlike most intrinsics, this is safe to call;
754
+ /// it does not require an `unsafe` block.
755
+ /// Therefore, implementations must not require the user to uphold
756
+ /// any safety invariants.
757
+ ///
748
758
/// This intrinsic does not have a stable counterpart.
749
759
#[ rustc_const_unstable( feature = "const_likely" , issue = "none" ) ]
750
760
pub fn likely ( b : bool ) -> bool ;
@@ -754,6 +764,11 @@ extern "rust-intrinsic" {
754
764
///
755
765
/// Any use other than with `if` statements will probably not have an effect.
756
766
///
767
+ /// Note that, unlike most intrinsics, this is safe to call;
768
+ /// it does not require an `unsafe` block.
769
+ /// Therefore, implementations must not require the user to uphold
770
+ /// any safety invariants.
771
+ ///
757
772
/// This intrinsic does not have a stable counterpart.
758
773
#[ rustc_const_unstable( feature = "const_likely" , issue = "none" ) ]
759
774
pub fn unlikely ( b : bool ) -> bool ;
@@ -765,6 +780,11 @@ extern "rust-intrinsic" {
765
780
766
781
/// The size of a type in bytes.
767
782
///
783
+ /// Note that, unlike most intrinsics, this is safe to call;
784
+ /// it does not require an `unsafe` block.
785
+ /// Therefore, implementations must not require the user to uphold
786
+ /// any safety invariants.
787
+ ///
768
788
/// More specifically, this is the offset in bytes between successive
769
789
/// items of the same type, including alignment padding.
770
790
///
@@ -774,6 +794,11 @@ extern "rust-intrinsic" {
774
794
775
795
/// The minimum alignment of a type.
776
796
///
797
+ /// Note that, unlike most intrinsics, this is safe to call;
798
+ /// it does not require an `unsafe` block.
799
+ /// Therefore, implementations must not require the user to uphold
800
+ /// any safety invariants.
801
+ ///
777
802
/// The stabilized version of this intrinsic is [`core::mem::align_of`].
778
803
#[ rustc_const_stable( feature = "const_min_align_of" , since = "1.40.0" ) ]
779
804
pub fn min_align_of < T > ( ) -> usize ;
@@ -796,6 +821,11 @@ extern "rust-intrinsic" {
796
821
797
822
/// Gets a static string slice containing the name of a type.
798
823
///
824
+ /// Note that, unlike most intrinsics, this is safe to call;
825
+ /// it does not require an `unsafe` block.
826
+ /// Therefore, implementations must not require the user to uphold
827
+ /// any safety invariants.
828
+ ///
799
829
/// The stabilized version of this intrinsic is [`core::any::type_name`].
800
830
#[ rustc_const_unstable( feature = "const_type_name" , issue = "63084" ) ]
801
831
pub fn type_name < T : ?Sized > ( ) -> & ' static str ;
@@ -804,6 +834,11 @@ extern "rust-intrinsic" {
804
834
/// function will return the same value for a type regardless of whichever
805
835
/// crate it is invoked in.
806
836
///
837
+ /// Note that, unlike most intrinsics, this is safe to call;
838
+ /// it does not require an `unsafe` block.
839
+ /// Therefore, implementations must not require the user to uphold
840
+ /// any safety invariants.
841
+ ///
807
842
/// The stabilized version of this intrinsic is [`core::any::TypeId::of`].
808
843
#[ rustc_const_unstable( feature = "const_type_id" , issue = "77125" ) ]
809
844
pub fn type_id < T : ?Sized + ' static > ( ) -> u64 ;
@@ -829,6 +864,11 @@ extern "rust-intrinsic" {
829
864
830
865
/// Gets a reference to a static `Location` indicating where it was called.
831
866
///
867
+ /// Note that, unlike most intrinsics, this is safe to call;
868
+ /// it does not require an `unsafe` block.
869
+ /// Therefore, implementations must not require the user to uphold
870
+ /// any safety invariants.
871
+ ///
832
872
/// Consider using [`core::panic::Location::caller`] instead.
833
873
#[ rustc_const_unstable( feature = "const_caller_location" , issue = "76156" ) ]
834
874
pub fn caller_location ( ) -> & ' static crate :: panic:: Location < ' static > ;
@@ -837,6 +877,11 @@ extern "rust-intrinsic" {
837
877
///
838
878
/// This exists solely for [`mem::forget_unsized`]; normal `forget` uses
839
879
/// `ManuallyDrop` instead.
880
+ ///
881
+ /// Note that, unlike most intrinsics, this is safe to call;
882
+ /// it does not require an `unsafe` block.
883
+ /// Therefore, implementations must not require the user to uphold
884
+ /// any safety invariants.
840
885
#[ rustc_const_unstable( feature = "const_intrinsic_forget" , issue = "none" ) ]
841
886
pub fn forget < T : ?Sized > ( _: T ) ;
842
887
@@ -1090,6 +1135,11 @@ extern "rust-intrinsic" {
1090
1135
/// If the actual type neither requires drop glue nor implements
1091
1136
/// `Copy`, then the return value of this function is unspecified.
1092
1137
///
1138
+ /// Note that, unlike most intrinsics, this is safe to call;
1139
+ /// it does not require an `unsafe` block.
1140
+ /// Therefore, implementations must not require the user to uphold
1141
+ /// any safety invariants.
1142
+ ///
1093
1143
/// The stabilized version of this intrinsic is [`mem::needs_drop`](crate::mem::needs_drop).
1094
1144
#[ rustc_const_stable( feature = "const_needs_drop" , since = "1.40.0" ) ]
1095
1145
pub fn needs_drop < T > ( ) -> bool ;
@@ -1310,21 +1360,41 @@ extern "rust-intrinsic" {
1310
1360
1311
1361
/// Returns the minimum of two `f32` values.
1312
1362
///
1363
+ /// Note that, unlike most intrinsics, this is safe to call;
1364
+ /// it does not require an `unsafe` block.
1365
+ /// Therefore, implementations must not require the user to uphold
1366
+ /// any safety invariants.
1367
+ ///
1313
1368
/// The stabilized version of this intrinsic is
1314
1369
/// [`f32::min`]
1315
1370
pub fn minnumf32 ( x : f32 , y : f32 ) -> f32 ;
1316
1371
/// Returns the minimum of two `f64` values.
1317
1372
///
1373
+ /// Note that, unlike most intrinsics, this is safe to call;
1374
+ /// it does not require an `unsafe` block.
1375
+ /// Therefore, implementations must not require the user to uphold
1376
+ /// any safety invariants.
1377
+ ///
1318
1378
/// The stabilized version of this intrinsic is
1319
1379
/// [`f64::min`]
1320
1380
pub fn minnumf64 ( x : f64 , y : f64 ) -> f64 ;
1321
1381
/// Returns the maximum of two `f32` values.
1322
1382
///
1383
+ /// Note that, unlike most intrinsics, this is safe to call;
1384
+ /// it does not require an `unsafe` block.
1385
+ /// Therefore, implementations must not require the user to uphold
1386
+ /// any safety invariants.
1387
+ ///
1323
1388
/// The stabilized version of this intrinsic is
1324
1389
/// [`f32::max`]
1325
1390
pub fn maxnumf32 ( x : f32 , y : f32 ) -> f32 ;
1326
1391
/// Returns the maximum of two `f64` values.
1327
1392
///
1393
+ /// Note that, unlike most intrinsics, this is safe to call;
1394
+ /// it does not require an `unsafe` block.
1395
+ /// Therefore, implementations must not require the user to uphold
1396
+ /// any safety invariants.
1397
+ ///
1328
1398
/// The stabilized version of this intrinsic is
1329
1399
/// [`f64::max`]
1330
1400
pub fn maxnumf64 ( x : f64 , y : f64 ) -> f64 ;
@@ -1438,6 +1508,11 @@ extern "rust-intrinsic" {
1438
1508
1439
1509
/// Returns the number of bits set in an integer type `T`
1440
1510
///
1511
+ /// Note that, unlike most intrinsics, this is safe to call;
1512
+ /// it does not require an `unsafe` block.
1513
+ /// Therefore, implementations must not require the user to uphold
1514
+ /// any safety invariants.
1515
+ ///
1441
1516
/// The stabilized versions of this intrinsic are available on the integer
1442
1517
/// primitives via the `count_ones` method. For example,
1443
1518
/// [`u32::count_ones`]
@@ -1446,6 +1521,11 @@ extern "rust-intrinsic" {
1446
1521
1447
1522
/// Returns the number of leading unset bits (zeroes) in an integer type `T`.
1448
1523
///
1524
+ /// Note that, unlike most intrinsics, this is safe to call;
1525
+ /// it does not require an `unsafe` block.
1526
+ /// Therefore, implementations must not require the user to uphold
1527
+ /// any safety invariants.
1528
+ ///
1449
1529
/// The stabilized versions of this intrinsic are available on the integer
1450
1530
/// primitives via the `leading_zeros` method. For example,
1451
1531
/// [`u32::leading_zeros`]
@@ -1497,6 +1577,11 @@ extern "rust-intrinsic" {
1497
1577
1498
1578
/// Returns the number of trailing unset bits (zeroes) in an integer type `T`.
1499
1579
///
1580
+ /// Note that, unlike most intrinsics, this is safe to call;
1581
+ /// it does not require an `unsafe` block.
1582
+ /// Therefore, implementations must not require the user to uphold
1583
+ /// any safety invariants.
1584
+ ///
1500
1585
/// The stabilized versions of this intrinsic are available on the integer
1501
1586
/// primitives via the `trailing_zeros` method. For example,
1502
1587
/// [`u32::trailing_zeros`]
@@ -1548,6 +1633,11 @@ extern "rust-intrinsic" {
1548
1633
1549
1634
/// Reverses the bytes in an integer type `T`.
1550
1635
///
1636
+ /// Note that, unlike most intrinsics, this is safe to call;
1637
+ /// it does not require an `unsafe` block.
1638
+ /// Therefore, implementations must not require the user to uphold
1639
+ /// any safety invariants.
1640
+ ///
1551
1641
/// The stabilized versions of this intrinsic are available on the integer
1552
1642
/// primitives via the `swap_bytes` method. For example,
1553
1643
/// [`u32::swap_bytes`]
@@ -1556,6 +1646,11 @@ extern "rust-intrinsic" {
1556
1646
1557
1647
/// Reverses the bits in an integer type `T`.
1558
1648
///
1649
+ /// Note that, unlike most intrinsics, this is safe to call;
1650
+ /// it does not require an `unsafe` block.
1651
+ /// Therefore, implementations must not require the user to uphold
1652
+ /// any safety invariants.
1653
+ ///
1559
1654
/// The stabilized versions of this intrinsic are available on the integer
1560
1655
/// primitives via the `reverse_bits` method. For example,
1561
1656
/// [`u32::reverse_bits`]
@@ -1564,6 +1659,11 @@ extern "rust-intrinsic" {
1564
1659
1565
1660
/// Performs checked integer addition.
1566
1661
///
1662
+ /// Note that, unlike most intrinsics, this is safe to call;
1663
+ /// it does not require an `unsafe` block.
1664
+ /// Therefore, implementations must not require the user to uphold
1665
+ /// any safety invariants.
1666
+ ///
1567
1667
/// The stabilized versions of this intrinsic are available on the integer
1568
1668
/// primitives via the `overflowing_add` method. For example,
1569
1669
/// [`u32::overflowing_add`]
@@ -1572,6 +1672,11 @@ extern "rust-intrinsic" {
1572
1672
1573
1673
/// Performs checked integer subtraction
1574
1674
///
1675
+ /// Note that, unlike most intrinsics, this is safe to call;
1676
+ /// it does not require an `unsafe` block.
1677
+ /// Therefore, implementations must not require the user to uphold
1678
+ /// any safety invariants.
1679
+ ///
1575
1680
/// The stabilized versions of this intrinsic are available on the integer
1576
1681
/// primitives via the `overflowing_sub` method. For example,
1577
1682
/// [`u32::overflowing_sub`]
@@ -1580,6 +1685,11 @@ extern "rust-intrinsic" {
1580
1685
1581
1686
/// Performs checked integer multiplication
1582
1687
///
1688
+ /// Note that, unlike most intrinsics, this is safe to call;
1689
+ /// it does not require an `unsafe` block.
1690
+ /// Therefore, implementations must not require the user to uphold
1691
+ /// any safety invariants.
1692
+ ///
1583
1693
/// The stabilized versions of this intrinsic are available on the integer
1584
1694
/// primitives via the `overflowing_mul` method. For example,
1585
1695
/// [`u32::overflowing_mul`]
@@ -1649,6 +1759,11 @@ extern "rust-intrinsic" {
1649
1759
1650
1760
/// Performs rotate left.
1651
1761
///
1762
+ /// Note that, unlike most intrinsics, this is safe to call;
1763
+ /// it does not require an `unsafe` block.
1764
+ /// Therefore, implementations must not require the user to uphold
1765
+ /// any safety invariants.
1766
+ ///
1652
1767
/// The stabilized versions of this intrinsic are available on the integer
1653
1768
/// primitives via the `rotate_left` method. For example,
1654
1769
/// [`u32::rotate_left`]
@@ -1657,6 +1772,11 @@ extern "rust-intrinsic" {
1657
1772
1658
1773
/// Performs rotate right.
1659
1774
///
1775
+ /// Note that, unlike most intrinsics, this is safe to call;
1776
+ /// it does not require an `unsafe` block.
1777
+ /// Therefore, implementations must not require the user to uphold
1778
+ /// any safety invariants.
1779
+ ///
1660
1780
/// The stabilized versions of this intrinsic are available on the integer
1661
1781
/// primitives via the `rotate_right` method. For example,
1662
1782
/// [`u32::rotate_right`]
@@ -1665,20 +1785,35 @@ extern "rust-intrinsic" {
1665
1785
1666
1786
/// Returns (a + b) mod 2<sup>N</sup>, where N is the width of T in bits.
1667
1787
///
1788
+ /// Note that, unlike most intrinsics, this is safe to call;
1789
+ /// it does not require an `unsafe` block.
1790
+ /// Therefore, implementations must not require the user to uphold
1791
+ /// any safety invariants.
1792
+ ///
1668
1793
/// The stabilized versions of this intrinsic are available on the integer
1669
1794
/// primitives via the `wrapping_add` method. For example,
1670
1795
/// [`u32::wrapping_add`]
1671
1796
#[ rustc_const_stable( feature = "const_int_wrapping" , since = "1.40.0" ) ]
1672
1797
pub fn wrapping_add < T : Copy > ( a : T , b : T ) -> T ;
1673
1798
/// Returns (a - b) mod 2<sup>N</sup>, where N is the width of T in bits.
1674
1799
///
1800
+ /// Note that, unlike most intrinsics, this is safe to call;
1801
+ /// it does not require an `unsafe` block.
1802
+ /// Therefore, implementations must not require the user to uphold
1803
+ /// any safety invariants.
1804
+ ///
1675
1805
/// The stabilized versions of this intrinsic are available on the integer
1676
1806
/// primitives via the `wrapping_sub` method. For example,
1677
1807
/// [`u32::wrapping_sub`]
1678
1808
#[ rustc_const_stable( feature = "const_int_wrapping" , since = "1.40.0" ) ]
1679
1809
pub fn wrapping_sub < T : Copy > ( a : T , b : T ) -> T ;
1680
1810
/// Returns (a * b) mod 2<sup>N</sup>, where N is the width of T in bits.
1681
1811
///
1812
+ /// Note that, unlike most intrinsics, this is safe to call;
1813
+ /// it does not require an `unsafe` block.
1814
+ /// Therefore, implementations must not require the user to uphold
1815
+ /// any safety invariants.
1816
+ ///
1682
1817
/// The stabilized versions of this intrinsic are available on the integer
1683
1818
/// primitives via the `wrapping_mul` method. For example,
1684
1819
/// [`u32::wrapping_mul`]
@@ -1687,13 +1822,23 @@ extern "rust-intrinsic" {
1687
1822
1688
1823
/// Computes `a + b`, saturating at numeric bounds.
1689
1824
///
1825
+ /// Note that, unlike most intrinsics, this is safe to call;
1826
+ /// it does not require an `unsafe` block.
1827
+ /// Therefore, implementations must not require the user to uphold
1828
+ /// any safety invariants.
1829
+ ///
1690
1830
/// The stabilized versions of this intrinsic are available on the integer
1691
1831
/// primitives via the `saturating_add` method. For example,
1692
1832
/// [`u32::saturating_add`]
1693
1833
#[ rustc_const_stable( feature = "const_int_saturating" , since = "1.40.0" ) ]
1694
1834
pub fn saturating_add < T : Copy > ( a : T , b : T ) -> T ;
1695
1835
/// Computes `a - b`, saturating at numeric bounds.
1696
1836
///
1837
+ /// Note that, unlike most intrinsics, this is safe to call;
1838
+ /// it does not require an `unsafe` block.
1839
+ /// Therefore, implementations must not require the user to uphold
1840
+ /// any safety invariants.
1841
+ ///
1697
1842
/// The stabilized versions of this intrinsic are available on the integer
1698
1843
/// primitives via the `saturating_sub` method. For example,
1699
1844
/// [`u32::saturating_sub`]
@@ -1703,13 +1848,23 @@ extern "rust-intrinsic" {
1703
1848
/// Returns the value of the discriminant for the variant in 'v';
1704
1849
/// if `T` has no discriminant, returns `0`.
1705
1850
///
1851
+ /// Note that, unlike most intrinsics, this is safe to call;
1852
+ /// it does not require an `unsafe` block.
1853
+ /// Therefore, implementations must not require the user to uphold
1854
+ /// any safety invariants.
1855
+ ///
1706
1856
/// The stabilized version of this intrinsic is [`core::mem::discriminant`].
1707
1857
#[ rustc_const_unstable( feature = "const_discriminant" , issue = "69821" ) ]
1708
1858
pub fn discriminant_value < T > ( v : & T ) -> <T as DiscriminantKind >:: Discriminant ;
1709
1859
1710
1860
/// Returns the number of variants of the type `T` cast to a `usize`;
1711
1861
/// if `T` has no variants, returns `0`. Uninhabited variants will be counted.
1712
1862
///
1863
+ /// Note that, unlike most intrinsics, this is safe to call;
1864
+ /// it does not require an `unsafe` block.
1865
+ /// Therefore, implementations must not require the user to uphold
1866
+ /// any safety invariants.
1867
+ ///
1713
1868
/// The to-be-stabilized version of this intrinsic is [`mem::variant_count`].
1714
1869
#[ rustc_const_unstable( feature = "variant_count" , issue = "73662" ) ]
1715
1870
pub fn variant_count < T > ( ) -> usize ;
@@ -1732,10 +1887,20 @@ extern "rust-intrinsic" {
1732
1887
pub fn ptr_offset_from < T > ( ptr : * const T , base : * const T ) -> isize ;
1733
1888
1734
1889
/// See documentation of `<*const T>::guaranteed_eq` for details.
1890
+ ///
1891
+ /// Note that, unlike most intrinsics, this is safe to call;
1892
+ /// it does not require an `unsafe` block.
1893
+ /// Therefore, implementations must not require the user to uphold
1894
+ /// any safety invariants.
1735
1895
#[ rustc_const_unstable( feature = "const_raw_ptr_comparison" , issue = "53020" ) ]
1736
1896
pub fn ptr_guaranteed_eq < T > ( ptr : * const T , other : * const T ) -> bool ;
1737
1897
1738
1898
/// See documentation of `<*const T>::guaranteed_ne` for details.
1899
+ ///
1900
+ /// Note that, unlike most intrinsics, this is safe to call;
1901
+ /// it does not require an `unsafe` block.
1902
+ /// Therefore, implementations must not require the user to uphold
1903
+ /// any safety invariants.
1739
1904
#[ rustc_const_unstable( feature = "const_raw_ptr_comparison" , issue = "53020" ) ]
1740
1905
pub fn ptr_guaranteed_ne < T > ( ptr : * const T , other : * const T ) -> bool ;
1741
1906
0 commit comments