@@ -500,21 +500,25 @@ macro_rules! uint_impl {
500
500
/// Unchecked integer addition. Computes `self + rhs`, assuming overflow
501
501
/// cannot occur.
502
502
///
503
+ /// Calling `x.unchecked_add(y)` is semantically equivalent to calling
504
+ /// `x.`[`checked_add`]`(y).`[`unwrap_unchecked`]`()`.
505
+ ///
506
+ /// If you're just trying to avoid the panic in debug mode, then **do not**
507
+ /// use this. Instead, you're looking for [`wrapping_add`].
508
+ ///
503
509
/// # Safety
504
510
///
505
511
/// This results in undefined behavior when
506
512
#[ doc = concat!( "`self + rhs > " , stringify!( $SelfT) , "::MAX` or `self + rhs < " , stringify!( $SelfT) , "::MIN`," ) ]
507
513
/// i.e. when [`checked_add`] would return `None`.
508
514
///
515
+ /// [`unwrap_unchecked`]: Option::unwrap_unchecked
509
516
#[ doc = concat!( "[`checked_add`]: " , stringify!( $SelfT) , "::checked_add" ) ]
510
- #[ unstable(
511
- feature = "unchecked_math" ,
512
- reason = "niche optimization path" ,
513
- issue = "85122" ,
514
- ) ]
517
+ #[ doc = concat!( "[`wrapping_add`]: " , stringify!( $SelfT) , "::wrapping_add" ) ]
518
+ #[ stable( feature = "unchecked_math" , since = "CURRENT_RUSTC_VERSION" ) ]
519
+ #[ rustc_const_stable( feature = "unchecked_math" , since = "CURRENT_RUSTC_VERSION" ) ]
515
520
#[ must_use = "this returns the result of the operation, \
516
521
without modifying the original"]
517
- #[ rustc_const_unstable( feature = "unchecked_math" , issue = "85122" ) ]
518
522
#[ inline( always) ]
519
523
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
520
524
pub const unsafe fn unchecked_add( self , rhs: Self ) -> Self {
@@ -644,21 +648,25 @@ macro_rules! uint_impl {
644
648
/// Unchecked integer subtraction. Computes `self - rhs`, assuming overflow
645
649
/// cannot occur.
646
650
///
651
+ /// Calling `x.unchecked_sub(y)` is semantically equivalent to calling
652
+ /// `x.`[`checked_sub`]`(y).`[`unwrap_unchecked`]`()`.
653
+ ///
654
+ /// If you're just trying to avoid the panic in debug mode, then **do not**
655
+ /// use this. Instead, you're looking for [`wrapping_sub`].
656
+ ///
647
657
/// # Safety
648
658
///
649
659
/// This results in undefined behavior when
650
660
#[ doc = concat!( "`self - rhs > " , stringify!( $SelfT) , "::MAX` or `self - rhs < " , stringify!( $SelfT) , "::MIN`," ) ]
651
661
/// i.e. when [`checked_sub`] would return `None`.
652
662
///
663
+ /// [`unwrap_unchecked`]: Option::unwrap_unchecked
653
664
#[ doc = concat!( "[`checked_sub`]: " , stringify!( $SelfT) , "::checked_sub" ) ]
654
- #[ unstable(
655
- feature = "unchecked_math" ,
656
- reason = "niche optimization path" ,
657
- issue = "85122" ,
658
- ) ]
665
+ #[ doc = concat!( "[`wrapping_sub`]: " , stringify!( $SelfT) , "::wrapping_sub" ) ]
666
+ #[ stable( feature = "unchecked_math" , since = "CURRENT_RUSTC_VERSION" ) ]
667
+ #[ rustc_const_stable( feature = "unchecked_math" , since = "CURRENT_RUSTC_VERSION" ) ]
659
668
#[ must_use = "this returns the result of the operation, \
660
669
without modifying the original"]
661
- #[ rustc_const_unstable( feature = "unchecked_math" , issue = "85122" ) ]
662
670
#[ inline( always) ]
663
671
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
664
672
pub const unsafe fn unchecked_sub( self , rhs: Self ) -> Self {
@@ -726,21 +734,25 @@ macro_rules! uint_impl {
726
734
/// Unchecked integer multiplication. Computes `self * rhs`, assuming overflow
727
735
/// cannot occur.
728
736
///
737
+ /// Calling `x.unchecked_mul(y)` is semantically equivalent to calling
738
+ /// `x.`[`checked_mul`]`(y).`[`unwrap_unchecked`]`()`.
739
+ ///
740
+ /// If you're just trying to avoid the panic in debug mode, then **do not**
741
+ /// use this. Instead, you're looking for [`wrapping_mul`].
742
+ ///
729
743
/// # Safety
730
744
///
731
745
/// This results in undefined behavior when
732
746
#[ doc = concat!( "`self * rhs > " , stringify!( $SelfT) , "::MAX` or `self * rhs < " , stringify!( $SelfT) , "::MIN`," ) ]
733
747
/// i.e. when [`checked_mul`] would return `None`.
734
748
///
749
+ /// [`unwrap_unchecked`]: Option::unwrap_unchecked
735
750
#[ doc = concat!( "[`checked_mul`]: " , stringify!( $SelfT) , "::checked_mul" ) ]
736
- #[ unstable(
737
- feature = "unchecked_math" ,
738
- reason = "niche optimization path" ,
739
- issue = "85122" ,
740
- ) ]
751
+ #[ doc = concat!( "[`wrapping_mul`]: " , stringify!( $SelfT) , "::wrapping_mul" ) ]
752
+ #[ stable( feature = "unchecked_math" , since = "CURRENT_RUSTC_VERSION" ) ]
753
+ #[ rustc_const_stable( feature = "unchecked_math" , since = "CURRENT_RUSTC_VERSION" ) ]
741
754
#[ must_use = "this returns the result of the operation, \
742
755
without modifying the original"]
743
- #[ rustc_const_unstable( feature = "unchecked_math" , issue = "85122" ) ]
744
756
#[ inline( always) ]
745
757
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
746
758
pub const unsafe fn unchecked_mul( self , rhs: Self ) -> Self {
0 commit comments