Skip to content

Commit ba3e535

Browse files
authored
Rollup merge of #112644 - zica87:nonZeroTypes, r=Mark-Simulacrum
Correct types in method descriptions of `NonZero*` types - `$Int`: e.g. i32, usize - `$Ty`: e.g. NonZeroI32, NonZeroUsize |method|current description|after my changes| |-|-|-| |`saturating_add`|...Return `$Int`::MAX on overflow.|...Return `$Ty`::MAX on overflow.| |`checked_abs`|...returns None if self == `$Int`::MIN.|...returns None if self == `$Ty`::MIN.| |`checked_neg`|...returning None if self == i32::MIN.|...returning None if self == `$Ty`::MIN.| |`saturating_neg`|...returning MAX if self == i32::MIN...|...returning `$Ty`::MAX if self == `$Ty`::MIN...| |`saturating_mul`|...Return `$Int`::MAX...|...Return `$Ty`::MAX...| |`saturating_pow`|...Return `$Int`::MIN or `$Int`::MAX...|...Return `$Ty`::MIN or `$Ty`::MAX...| --- For example: ```rust pub const fn saturating_neg(self) -> NonZeroI128 ``` - current - Saturating negation. Computes `-self`, returning `MAX` if `self == i32::MIN` instead of overflowing. - after my changes - Saturating negation. Computes `-self`, returning `NonZeroI128::MAX` if `self == NonZeroI128::MIN` instead of overflowing.
2 parents d2120b7 + 88b0858 commit ba3e535

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

library/core/src/num/nonzero.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ macro_rules! nonzero_unsigned_operations {
348348
}
349349

350350
/// Adds an unsigned integer to a non-zero value.
351-
#[doc = concat!("Return [`", stringify!($Int), "::MAX`] on overflow.")]
351+
#[doc = concat!("Return [`", stringify!($Ty), "::MAX`] on overflow.")]
352352
///
353353
/// # Examples
354354
///
@@ -579,7 +579,7 @@ macro_rules! nonzero_signed_operations {
579579

580580
/// Checked absolute value.
581581
/// Checks for overflow and returns [`None`] if
582-
#[doc = concat!("`self == ", stringify!($Int), "::MIN`.")]
582+
#[doc = concat!("`self == ", stringify!($Ty), "::MIN`.")]
583583
/// The result cannot be zero.
584584
///
585585
/// # Example
@@ -800,7 +800,8 @@ macro_rules! nonzero_signed_operations {
800800
self.get().is_negative()
801801
}
802802

803-
/// Checked negation. Computes `-self`, returning `None` if `self == i32::MIN`.
803+
/// Checked negation. Computes `-self`,
804+
#[doc = concat!("returning `None` if `self == ", stringify!($Ty), "::MIN`.")]
804805
///
805806
/// # Example
806807
///
@@ -859,8 +860,10 @@ macro_rules! nonzero_signed_operations {
859860
((unsafe { $Ty::new_unchecked(result) }), overflow)
860861
}
861862

862-
/// Saturating negation. Computes `-self`, returning `MAX` if
863-
/// `self == i32::MIN` instead of overflowing.
863+
/// Saturating negation. Computes `-self`,
864+
#[doc = concat!("returning [`", stringify!($Ty), "::MAX`]")]
865+
#[doc = concat!("if `self == ", stringify!($Ty), "::MIN`")]
866+
/// instead of overflowing.
864867
///
865868
/// # Example
866869
///
@@ -993,7 +996,7 @@ macro_rules! nonzero_unsigned_signed_operations {
993996
}
994997

995998
/// Multiplies two non-zero integers together.
996-
#[doc = concat!("Return [`", stringify!($Int), "::MAX`] on overflow.")]
999+
#[doc = concat!("Return [`", stringify!($Ty), "::MAX`] on overflow.")]
9971000
///
9981001
/// # Examples
9991002
///
@@ -1102,11 +1105,11 @@ macro_rules! nonzero_unsigned_signed_operations {
11021105
#[doc = sign_dependent_expr!{
11031106
$signedness ?
11041107
if signed {
1105-
concat!("Return [`", stringify!($Int), "::MIN`] ",
1106-
"or [`", stringify!($Int), "::MAX`] on overflow.")
1108+
concat!("Return [`", stringify!($Ty), "::MIN`] ",
1109+
"or [`", stringify!($Ty), "::MAX`] on overflow.")
11071110
}
11081111
if unsigned {
1109-
concat!("Return [`", stringify!($Int), "::MAX`] on overflow.")
1112+
concat!("Return [`", stringify!($Ty), "::MAX`] on overflow.")
11101113
}
11111114
}]
11121115
///

0 commit comments

Comments
 (0)