@@ -1123,6 +1123,10 @@ macro_rules! uint_impl {
1123
1123
/// Saturating integer division. Computes `self / rhs`, saturating at the
1124
1124
/// numeric bounds instead of overflowing.
1125
1125
///
1126
+ /// # Panics
1127
+ ///
1128
+ /// This function will panic if `rhs` is 0.
1129
+ ///
1126
1130
/// # Examples
1127
1131
///
1128
1132
/// Basic usage:
@@ -1131,16 +1135,12 @@ macro_rules! uint_impl {
1131
1135
#[ doc = concat!( "assert_eq!(5" , stringify!( $SelfT) , ".saturating_div(2), 2);" ) ]
1132
1136
///
1133
1137
/// ```
1134
- ///
1135
- /// ```should_panic
1136
- #[ doc = concat!( "let _ = 1" , stringify!( $SelfT) , ".saturating_div(0);" ) ]
1137
- ///
1138
- /// ```
1139
1138
#[ stable( feature = "saturating_div" , since = "1.58.0" ) ]
1140
1139
#[ rustc_const_stable( feature = "saturating_div" , since = "1.58.0" ) ]
1141
1140
#[ must_use = "this returns the result of the operation, \
1142
1141
without modifying the original"]
1143
1142
#[ inline]
1143
+ #[ track_caller]
1144
1144
pub const fn saturating_div( self , rhs: Self ) -> Self {
1145
1145
// on unsigned types, there is no overflow in integer division
1146
1146
self . wrapping_div( rhs)
@@ -1275,6 +1275,7 @@ macro_rules! uint_impl {
1275
1275
#[ must_use = "this returns the result of the operation, \
1276
1276
without modifying the original"]
1277
1277
#[ inline( always) ]
1278
+ #[ track_caller]
1278
1279
pub const fn wrapping_div( self , rhs: Self ) -> Self {
1279
1280
self / rhs
1280
1281
}
@@ -1304,6 +1305,7 @@ macro_rules! uint_impl {
1304
1305
#[ must_use = "this returns the result of the operation, \
1305
1306
without modifying the original"]
1306
1307
#[ inline( always) ]
1308
+ #[ track_caller]
1307
1309
pub const fn wrapping_div_euclid( self , rhs: Self ) -> Self {
1308
1310
self / rhs
1309
1311
}
@@ -1331,6 +1333,7 @@ macro_rules! uint_impl {
1331
1333
#[ must_use = "this returns the result of the operation, \
1332
1334
without modifying the original"]
1333
1335
#[ inline( always) ]
1336
+ #[ track_caller]
1334
1337
pub const fn wrapping_rem( self , rhs: Self ) -> Self {
1335
1338
self % rhs
1336
1339
}
@@ -1361,6 +1364,7 @@ macro_rules! uint_impl {
1361
1364
#[ must_use = "this returns the result of the operation, \
1362
1365
without modifying the original"]
1363
1366
#[ inline( always) ]
1367
+ #[ track_caller]
1364
1368
pub const fn wrapping_rem_euclid( self , rhs: Self ) -> Self {
1365
1369
self % rhs
1366
1370
}
@@ -1743,6 +1747,7 @@ macro_rules! uint_impl {
1743
1747
#[ rustc_const_stable( feature = "const_overflowing_int_methods" , since = "1.52.0" ) ]
1744
1748
#[ must_use = "this returns the result of the operation, \
1745
1749
without modifying the original"]
1750
+ #[ track_caller]
1746
1751
pub const fn overflowing_div( self , rhs: Self ) -> ( Self , bool ) {
1747
1752
( self / rhs, false )
1748
1753
}
@@ -1773,6 +1778,7 @@ macro_rules! uint_impl {
1773
1778
#[ rustc_const_stable( feature = "const_euclidean_int_methods" , since = "1.52.0" ) ]
1774
1779
#[ must_use = "this returns the result of the operation, \
1775
1780
without modifying the original"]
1781
+ #[ track_caller]
1776
1782
pub const fn overflowing_div_euclid( self , rhs: Self ) -> ( Self , bool ) {
1777
1783
( self / rhs, false )
1778
1784
}
@@ -1800,6 +1806,7 @@ macro_rules! uint_impl {
1800
1806
#[ rustc_const_stable( feature = "const_overflowing_int_methods" , since = "1.52.0" ) ]
1801
1807
#[ must_use = "this returns the result of the operation, \
1802
1808
without modifying the original"]
1809
+ #[ track_caller]
1803
1810
pub const fn overflowing_rem( self , rhs: Self ) -> ( Self , bool ) {
1804
1811
( self % rhs, false )
1805
1812
}
@@ -1830,6 +1837,7 @@ macro_rules! uint_impl {
1830
1837
#[ rustc_const_stable( feature = "const_euclidean_int_methods" , since = "1.52.0" ) ]
1831
1838
#[ must_use = "this returns the result of the operation, \
1832
1839
without modifying the original"]
1840
+ #[ track_caller]
1833
1841
pub const fn overflowing_rem_euclid( self , rhs: Self ) -> ( Self , bool ) {
1834
1842
( self % rhs, false )
1835
1843
}
@@ -2065,7 +2073,7 @@ macro_rules! uint_impl {
2065
2073
#[ must_use = "this returns the result of the operation, \
2066
2074
without modifying the original"]
2067
2075
#[ inline( always) ]
2068
- #[ rustc_inherit_overflow_checks ]
2076
+ #[ track_caller ]
2069
2077
pub const fn div_euclid( self , rhs: Self ) -> Self {
2070
2078
self / rhs
2071
2079
}
@@ -2094,7 +2102,7 @@ macro_rules! uint_impl {
2094
2102
#[ must_use = "this returns the result of the operation, \
2095
2103
without modifying the original"]
2096
2104
#[ inline( always) ]
2097
- #[ rustc_inherit_overflow_checks ]
2105
+ #[ track_caller ]
2098
2106
pub const fn rem_euclid( self , rhs: Self ) -> Self {
2099
2107
self % rhs
2100
2108
}
@@ -2119,6 +2127,7 @@ macro_rules! uint_impl {
2119
2127
#[ must_use = "this returns the result of the operation, \
2120
2128
without modifying the original"]
2121
2129
#[ inline( always) ]
2130
+ #[ track_caller]
2122
2131
pub const fn div_floor( self , rhs: Self ) -> Self {
2123
2132
self / rhs
2124
2133
}
@@ -2129,11 +2138,6 @@ macro_rules! uint_impl {
2129
2138
///
2130
2139
/// This function will panic if `rhs` is zero.
2131
2140
///
2132
- /// ## Overflow behavior
2133
- ///
2134
- /// On overflow, this function will panic if overflow checks are enabled (default in debug
2135
- /// mode) and wrap if overflow checks are disabled (default in release mode).
2136
- ///
2137
2141
/// # Examples
2138
2142
///
2139
2143
/// Basic usage:
@@ -2146,7 +2150,7 @@ macro_rules! uint_impl {
2146
2150
#[ must_use = "this returns the result of the operation, \
2147
2151
without modifying the original"]
2148
2152
#[ inline]
2149
- #[ rustc_inherit_overflow_checks ]
2153
+ #[ track_caller ]
2150
2154
pub const fn div_ceil( self , rhs: Self ) -> Self {
2151
2155
let d = self / rhs;
2152
2156
let r = self % rhs;
0 commit comments