@@ -500,21 +500,25 @@ macro_rules! uint_impl {
500500 /// Unchecked integer addition. Computes `self + rhs`, assuming overflow
501501 /// cannot occur.
502502 ///
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+ ///
503509 /// # Safety
504510 ///
505511 /// This results in undefined behavior when
506512 #[ doc = concat!( "`self + rhs > " , stringify!( $SelfT) , "::MAX` or `self + rhs < " , stringify!( $SelfT) , "::MIN`," ) ]
507513 /// i.e. when [`checked_add`] would return `None`.
508514 ///
515+ /// [`unwrap_unchecked`]: Option::unwrap_unchecked
509516 #[ 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" ) ]
515520 #[ must_use = "this returns the result of the operation, \
516521 without modifying the original"]
517- #[ rustc_const_unstable( feature = "unchecked_math" , issue = "85122" ) ]
518522 #[ inline( always) ]
519523 #[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
520524 pub const unsafe fn unchecked_add( self , rhs: Self ) -> Self {
@@ -644,21 +648,25 @@ macro_rules! uint_impl {
644648 /// Unchecked integer subtraction. Computes `self - rhs`, assuming overflow
645649 /// cannot occur.
646650 ///
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+ ///
647657 /// # Safety
648658 ///
649659 /// This results in undefined behavior when
650660 #[ doc = concat!( "`self - rhs > " , stringify!( $SelfT) , "::MAX` or `self - rhs < " , stringify!( $SelfT) , "::MIN`," ) ]
651661 /// i.e. when [`checked_sub`] would return `None`.
652662 ///
663+ /// [`unwrap_unchecked`]: Option::unwrap_unchecked
653664 #[ 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" ) ]
659668 #[ must_use = "this returns the result of the operation, \
660669 without modifying the original"]
661- #[ rustc_const_unstable( feature = "unchecked_math" , issue = "85122" ) ]
662670 #[ inline( always) ]
663671 #[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
664672 pub const unsafe fn unchecked_sub( self , rhs: Self ) -> Self {
@@ -726,21 +734,25 @@ macro_rules! uint_impl {
726734 /// Unchecked integer multiplication. Computes `self * rhs`, assuming overflow
727735 /// cannot occur.
728736 ///
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+ ///
729743 /// # Safety
730744 ///
731745 /// This results in undefined behavior when
732746 #[ doc = concat!( "`self * rhs > " , stringify!( $SelfT) , "::MAX` or `self * rhs < " , stringify!( $SelfT) , "::MIN`," ) ]
733747 /// i.e. when [`checked_mul`] would return `None`.
734748 ///
749+ /// [`unwrap_unchecked`]: Option::unwrap_unchecked
735750 #[ 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" ) ]
741754 #[ must_use = "this returns the result of the operation, \
742755 without modifying the original"]
743- #[ rustc_const_unstable( feature = "unchecked_math" , issue = "85122" ) ]
744756 #[ inline( always) ]
745757 #[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
746758 pub const unsafe fn unchecked_mul( self , rhs: Self ) -> Self {
0 commit comments