From 0bfdb188553f1acffe9051c2047768c892b18fac Mon Sep 17 00:00:00 2001 From: aisr Date: Mon, 20 Apr 2026 22:46:10 +0800 Subject: [PATCH] add safety sections to two unsafe methods in NonZero --- library/core/src/num/nonzero.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 7cb022b08290..59c37a7ce963 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -1118,7 +1118,10 @@ pub const fn saturating_mul(self, other: Self) -> Self { /// assuming overflow cannot occur. /// Overflow is unchecked, and it is undefined behavior to overflow /// *even if the result would wrap to a non-zero value*. - /// The behavior is undefined as soon as + /// + /// # Safety + /// + /// This results in undefined behavior when #[doc = sign_dependent_expr!{ $signedness ? if signed { @@ -1695,7 +1698,10 @@ pub const fn saturating_add(self, other: $Int) -> Self { /// assuming overflow cannot occur. /// Overflow is unchecked, and it is undefined behavior to overflow /// *even if the result would wrap to a non-zero value*. - /// The behavior is undefined as soon as + /// + /// # Safety + /// + /// This results in undefined behavior when #[doc = concat!("`self + rhs > ", stringify!($Int), "::MAX`.")] /// /// # Examples