@@ -1531,6 +1531,10 @@ macro_rules! uint_impl {
1531
1531
/// Saturating integer division. Computes `self / rhs`, saturating at the
1532
1532
/// numeric bounds instead of overflowing.
1533
1533
///
1534
+ /// # Panics
1535
+ ///
1536
+ /// This function will panic if `rhs` is 0.
1537
+ ///
1534
1538
/// # Examples
1535
1539
///
1536
1540
/// Basic usage:
@@ -1539,16 +1543,12 @@ macro_rules! uint_impl {
1539
1543
#[ doc = concat!( "assert_eq!(5" , stringify!( $SelfT) , ".saturating_div(2), 2);" ) ]
1540
1544
///
1541
1545
/// ```
1542
- ///
1543
- /// ```should_panic
1544
- #[ doc = concat!( "let _ = 1" , stringify!( $SelfT) , ".saturating_div(0);" ) ]
1545
- ///
1546
- /// ```
1547
1546
#[ stable( feature = "saturating_div" , since = "1.58.0" ) ]
1548
1547
#[ rustc_const_stable( feature = "saturating_div" , since = "1.58.0" ) ]
1549
1548
#[ must_use = "this returns the result of the operation, \
1550
1549
without modifying the original"]
1551
1550
#[ inline]
1551
+ #[ track_caller]
1552
1552
pub const fn saturating_div( self , rhs: Self ) -> Self {
1553
1553
// on unsigned types, there is no overflow in integer division
1554
1554
self . wrapping_div( rhs)
@@ -1683,6 +1683,7 @@ macro_rules! uint_impl {
1683
1683
#[ must_use = "this returns the result of the operation, \
1684
1684
without modifying the original"]
1685
1685
#[ inline( always) ]
1686
+ #[ track_caller]
1686
1687
pub const fn wrapping_div( self , rhs: Self ) -> Self {
1687
1688
self / rhs
1688
1689
}
@@ -1712,6 +1713,7 @@ macro_rules! uint_impl {
1712
1713
#[ must_use = "this returns the result of the operation, \
1713
1714
without modifying the original"]
1714
1715
#[ inline( always) ]
1716
+ #[ track_caller]
1715
1717
pub const fn wrapping_div_euclid( self , rhs: Self ) -> Self {
1716
1718
self / rhs
1717
1719
}
@@ -1739,6 +1741,7 @@ macro_rules! uint_impl {
1739
1741
#[ must_use = "this returns the result of the operation, \
1740
1742
without modifying the original"]
1741
1743
#[ inline( always) ]
1744
+ #[ track_caller]
1742
1745
pub const fn wrapping_rem( self , rhs: Self ) -> Self {
1743
1746
self % rhs
1744
1747
}
@@ -1769,6 +1772,7 @@ macro_rules! uint_impl {
1769
1772
#[ must_use = "this returns the result of the operation, \
1770
1773
without modifying the original"]
1771
1774
#[ inline( always) ]
1775
+ #[ track_caller]
1772
1776
pub const fn wrapping_rem_euclid( self , rhs: Self ) -> Self {
1773
1777
self % rhs
1774
1778
}
@@ -2151,6 +2155,7 @@ macro_rules! uint_impl {
2151
2155
#[ rustc_const_stable( feature = "const_overflowing_int_methods" , since = "1.52.0" ) ]
2152
2156
#[ must_use = "this returns the result of the operation, \
2153
2157
without modifying the original"]
2158
+ #[ track_caller]
2154
2159
pub const fn overflowing_div( self , rhs: Self ) -> ( Self , bool ) {
2155
2160
( self / rhs, false )
2156
2161
}
@@ -2181,6 +2186,7 @@ macro_rules! uint_impl {
2181
2186
#[ rustc_const_stable( feature = "const_euclidean_int_methods" , since = "1.52.0" ) ]
2182
2187
#[ must_use = "this returns the result of the operation, \
2183
2188
without modifying the original"]
2189
+ #[ track_caller]
2184
2190
pub const fn overflowing_div_euclid( self , rhs: Self ) -> ( Self , bool ) {
2185
2191
( self / rhs, false )
2186
2192
}
@@ -2208,6 +2214,7 @@ macro_rules! uint_impl {
2208
2214
#[ rustc_const_stable( feature = "const_overflowing_int_methods" , since = "1.52.0" ) ]
2209
2215
#[ must_use = "this returns the result of the operation, \
2210
2216
without modifying the original"]
2217
+ #[ track_caller]
2211
2218
pub const fn overflowing_rem( self , rhs: Self ) -> ( Self , bool ) {
2212
2219
( self % rhs, false )
2213
2220
}
@@ -2238,6 +2245,7 @@ macro_rules! uint_impl {
2238
2245
#[ rustc_const_stable( feature = "const_euclidean_int_methods" , since = "1.52.0" ) ]
2239
2246
#[ must_use = "this returns the result of the operation, \
2240
2247
without modifying the original"]
2248
+ #[ track_caller]
2241
2249
pub const fn overflowing_rem_euclid( self , rhs: Self ) -> ( Self , bool ) {
2242
2250
( self % rhs, false )
2243
2251
}
@@ -2473,7 +2481,7 @@ macro_rules! uint_impl {
2473
2481
#[ must_use = "this returns the result of the operation, \
2474
2482
without modifying the original"]
2475
2483
#[ inline( always) ]
2476
- #[ rustc_inherit_overflow_checks ]
2484
+ #[ track_caller ]
2477
2485
pub const fn div_euclid( self , rhs: Self ) -> Self {
2478
2486
self / rhs
2479
2487
}
@@ -2502,7 +2510,7 @@ macro_rules! uint_impl {
2502
2510
#[ must_use = "this returns the result of the operation, \
2503
2511
without modifying the original"]
2504
2512
#[ inline( always) ]
2505
- #[ rustc_inherit_overflow_checks ]
2513
+ #[ track_caller ]
2506
2514
pub const fn rem_euclid( self , rhs: Self ) -> Self {
2507
2515
self % rhs
2508
2516
}
@@ -2527,6 +2535,7 @@ macro_rules! uint_impl {
2527
2535
#[ must_use = "this returns the result of the operation, \
2528
2536
without modifying the original"]
2529
2537
#[ inline( always) ]
2538
+ #[ track_caller]
2530
2539
pub const fn div_floor( self , rhs: Self ) -> Self {
2531
2540
self / rhs
2532
2541
}
@@ -2537,11 +2546,6 @@ macro_rules! uint_impl {
2537
2546
///
2538
2547
/// This function will panic if `rhs` is zero.
2539
2548
///
2540
- /// ## Overflow behavior
2541
- ///
2542
- /// On overflow, this function will panic if overflow checks are enabled (default in debug
2543
- /// mode) and wrap if overflow checks are disabled (default in release mode).
2544
- ///
2545
2549
/// # Examples
2546
2550
///
2547
2551
/// Basic usage:
@@ -2554,7 +2558,7 @@ macro_rules! uint_impl {
2554
2558
#[ must_use = "this returns the result of the operation, \
2555
2559
without modifying the original"]
2556
2560
#[ inline]
2557
- #[ rustc_inherit_overflow_checks ]
2561
+ #[ track_caller ]
2558
2562
pub const fn div_ceil( self , rhs: Self ) -> Self {
2559
2563
let d = self / rhs;
2560
2564
let r = self % rhs;
0 commit comments