diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index ede69cb01c77a..96981a75d98f2 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -638,9 +638,8 @@ macro_rules! int_impl { /// /// # Safety /// - /// This results in undefined behavior when - #[doc = concat!("`self + rhs > ", stringify!($SelfT), "::MAX` or `self + rhs < ", stringify!($SelfT), "::MIN`,")] - /// i.e. when [`checked_add`] would return `None`. + /// This results in undefined behavior when overflow occurs, i.e. when + /// [`checked_add`] would return `None`. /// /// [`unwrap_unchecked`]: option/enum.Option.html#method.unwrap_unchecked #[doc = concat!("[`checked_add`]: ", stringify!($SelfT), "::checked_add")] @@ -778,9 +777,8 @@ macro_rules! int_impl { /// /// # Safety /// - /// This results in undefined behavior when - #[doc = concat!("`self - rhs > ", stringify!($SelfT), "::MAX` or `self - rhs < ", stringify!($SelfT), "::MIN`,")] - /// i.e. when [`checked_sub`] would return `None`. + /// This results in undefined behavior when overflow occurs, i.e. when + /// [`checked_sub`] would return `None`. /// /// [`unwrap_unchecked`]: option/enum.Option.html#method.unwrap_unchecked #[doc = concat!("[`checked_sub`]: ", stringify!($SelfT), "::checked_sub")] @@ -918,9 +916,8 @@ macro_rules! int_impl { /// /// # Safety /// - /// This results in undefined behavior when - #[doc = concat!("`self * rhs > ", stringify!($SelfT), "::MAX` or `self * rhs < ", stringify!($SelfT), "::MIN`,")] - /// i.e. when [`checked_mul`] would return `None`. + /// This results in undefined behavior when overflow occurs, i.e. when + /// [`checked_mul`] would return `None`. /// /// [`unwrap_unchecked`]: option/enum.Option.html#method.unwrap_unchecked #[doc = concat!("[`checked_mul`]: ", stringify!($SelfT), "::checked_mul")] diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index c97e6f4c45395..b32cc6050eec3 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -1274,17 +1274,8 @@ macro_rules! nonzero_integer { /// /// # Safety /// - /// This results in undefined behavior when - #[doc = sign_dependent_expr!{ - $signedness ? - if signed { - concat!("`self * rhs > ", stringify!($Int), "::MAX`, ", - "or `self * rhs < ", stringify!($Int), "::MIN`.") - } - if unsigned { - concat!("`self * rhs > ", stringify!($Int), "::MAX`.") - } - }] + /// This results in undefined behavior when overflow occurs, i.e. + /// when [`checked_mul`] would return `None`. /// /// # Examples /// @@ -1302,6 +1293,8 @@ macro_rules! nonzero_integer { /// # Some(()) /// # } /// ``` + /// + /// [`checked_mul`]: Self::checked_mul #[unstable(feature = "nonzero_ops", issue = "84186")] #[must_use = "this returns the result of the operation, \ without modifying the original"] @@ -1871,8 +1864,8 @@ macro_rules! nonzero_integer_signedness_dependent_methods { /// /// # Safety /// - /// This results in undefined behavior when - #[doc = concat!("`self + rhs > ", stringify!($Int), "::MAX`.")] + /// This results in undefined behavior when overflow occurs, i.e. when + /// [`checked_add`] would return `None`. /// /// # Examples /// @@ -1890,6 +1883,8 @@ macro_rules! nonzero_integer_signedness_dependent_methods { /// # Some(()) /// # } /// ``` + /// + /// [`checked_add`]: Self::checked_add #[unstable(feature = "nonzero_ops", issue = "84186")] #[must_use = "this returns the result of the operation, \ without modifying the original"] diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index 69352e9f3ed97..84107ec3f1883 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -1009,9 +1009,8 @@ macro_rules! uint_impl { /// /// # Safety /// - /// This results in undefined behavior when - #[doc = concat!("`self + rhs > ", stringify!($SelfT), "::MAX`,")] - /// i.e. when [`checked_add`] would return `None`. + /// This results in undefined behavior when overflow occurs, i.e. when + /// [`checked_add`] would return `None`. /// /// [`unwrap_unchecked`]: option/enum.Option.html#method.unwrap_unchecked #[doc = concat!("[`checked_add`]: ", stringify!($SelfT), "::checked_add")] @@ -1188,9 +1187,8 @@ macro_rules! uint_impl { /// /// # Safety /// - /// This results in undefined behavior when - #[doc = concat!("`self - rhs < ", stringify!($SelfT), "::MIN`,")] - /// i.e. when [`checked_sub`] would return `None`. + /// This results in undefined behavior when overflow occurs, i.e. when + /// [`checked_sub`] would return `None`. /// /// [`unwrap_unchecked`]: option/enum.Option.html#method.unwrap_unchecked #[doc = concat!("[`checked_sub`]: ", stringify!($SelfT), "::checked_sub")] @@ -1397,9 +1395,8 @@ macro_rules! uint_impl { /// /// # Safety /// - /// This results in undefined behavior when - #[doc = concat!("`self * rhs > ", stringify!($SelfT), "::MAX`,")] - /// i.e. when [`checked_mul`] would return `None`. + /// This results in undefined behavior when overflow occurs, i.e. when + /// [`checked_mul`] would return `None`. /// /// [`unwrap_unchecked`]: option/enum.Option.html#method.unwrap_unchecked #[doc = concat!("[`checked_mul`]: ", stringify!($SelfT), "::checked_mul")]