about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2025-08-02 11:24:29 +0200
committerGitHub <noreply@github.com>2025-08-02 11:24:29 +0200
commit5e1ea9cda4fba3703f3dc15522d7a50236b4f4f9 (patch)
tree8dadc199afa520a92c15fcba180228b596fce176
parent5bcc7c28726bd17a105cd83e19f93cee9517c256 (diff)
parent4c7c9de8acc7abc1788d6134716f3aeff8616300 (diff)
downloadrust-5e1ea9cda4fba3703f3dc15522d7a50236b4f4f9.tar.gz
rust-5e1ea9cda4fba3703f3dc15522d7a50236b4f4f9.zip
Rollup merge of #144797 - nilehmann:safety-comment-niche, r=Noratrieb
Update safety comment for new_unchecked in niche_types

Change the safety comment on `new_unchecked` to mention the valid range instead of 0. I noticed this while working on https://github.com/model-checking/verify-rust-std
-rw-r--r--library/core/src/num/niche_types.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/library/core/src/num/niche_types.rs b/library/core/src/num/niche_types.rs
index b92561c9e35..d57b1d433e5 100644
--- a/library/core/src/num/niche_types.rs
+++ b/library/core/src/num/niche_types.rs
@@ -46,11 +46,11 @@ macro_rules! define_valid_range_type {
             /// primitive without checking whether its zero.
             ///
             /// # Safety
-            /// Immediate language UB if `val == 0`, as it violates the validity
-            /// invariant of this type.
+            /// Immediate language UB if `val` is not within the valid range for this
+            /// type, as it violates the validity invariant.
             #[inline]
             pub const unsafe fn new_unchecked(val: $int) -> Self {
-                // SAFETY: Caller promised that `val` is non-zero.
+                // SAFETY: Caller promised that `val` is within the valid range.
                 unsafe { $name(val) }
             }