@@ -456,9 +456,13 @@ pub trait Div<Rhs = Self> {
456456}
457457
458458macro_rules! div_impl_integer {
459- ( $( $ t: ty) * ) => ( $(
459+ ( $( ( $ ( $ t: ty) * ) => $panic : expr ) , * ) => ( $ ( $(
460460 /// This operation rounds towards zero, truncating any
461461 /// fractional part of the exact result.
462+ ///
463+ /// # Panics
464+ ///
465+ #[ doc = $panic]
462466 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
463467 impl Div for $t {
464468 type Output = $t;
@@ -468,10 +472,13 @@ macro_rules! div_impl_integer {
468472 }
469473
470474 forward_ref_binop! { impl Div , div for $t, $t }
471- ) * )
475+ ) * ) * )
472476}
473477
474- div_impl_integer ! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
478+ div_impl_integer ! {
479+ ( usize u8 u16 u32 u64 u128 ) => "This operation will panic if `other == 0`." ,
480+ ( isize i8 i16 i32 i64 i128 ) => "This operation will panic if `other == 0` or the division results in overflow."
481+ }
475482
476483macro_rules! div_impl_float {
477484 ( $( $t: ty) * ) => ( $(
@@ -549,9 +556,13 @@ pub trait Rem<Rhs = Self> {
549556}
550557
551558macro_rules! rem_impl_integer {
552- ( $( $ t: ty) * ) => ( $(
559+ ( $( ( $ ( $ t: ty) * ) => $panic : expr ) , * ) => ( $ ( $(
553560 /// This operation satisfies `n % d == n - (n / d) * d`. The
554561 /// result has the same sign as the left operand.
562+ ///
563+ /// # Panics
564+ ///
565+ #[ doc = $panic]
555566 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
556567 impl Rem for $t {
557568 type Output = $t;
@@ -561,10 +572,13 @@ macro_rules! rem_impl_integer {
561572 }
562573
563574 forward_ref_binop! { impl Rem , rem for $t, $t }
564- ) * )
575+ ) * ) * )
565576}
566577
567- rem_impl_integer ! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
578+ rem_impl_integer ! {
579+ ( usize u8 u16 u32 u64 u128 ) => "This operation will panic if `other == 0`." ,
580+ ( isize i8 i16 i32 i64 i128 ) => "This operation will panic if `other == 0` or if `self / other` results in overflow."
581+ }
568582
569583macro_rules! rem_impl_float {
570584 ( $( $t: ty) * ) => ( $(
0 commit comments