From 256f0365580df52c9e7b88c61802688898c864d6 Mon Sep 17 00:00:00 2001 From: Lars Schumann Date: Sat, 4 Apr 2026 18:27:08 +0000 Subject: [PATCH] constify Step for NonZero ints --- library/core/src/iter/range.rs | 6 ++++-- library/core/src/num/nonzero.rs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/library/core/src/iter/range.rs b/library/core/src/iter/range.rs index c57f41ffbf06..3b025fdcda90 100644 --- a/library/core/src/iter/range.rs +++ b/library/core/src/iter/range.rs @@ -513,7 +513,8 @@ macro_rules! step_nonzero_impls { $( #[allow(unreachable_patterns)] #[unstable(feature = "step_trait", reason = "recently redesigned", issue = "42168")] - impl Step for NonZero<$narrower> { + #[rustc_const_unstable(feature = "step_trait", issue = "42168")] + impl const Step for NonZero<$narrower> { step_nonzero_identical_methods!($narrower); #[inline] @@ -538,7 +539,8 @@ fn backward_checked(start: Self, n: usize) -> Option { $( #[allow(unreachable_patterns)] #[unstable(feature = "step_trait", reason = "recently redesigned", issue = "42168")] - impl Step for NonZero<$wider> { + #[rustc_const_unstable(feature = "step_trait", issue = "42168")] + impl const Step for NonZero<$wider> { step_nonzero_identical_methods!($wider); #[inline] diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 3415e1d435ce..c270b947d4fd 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -184,7 +184,8 @@ impl $Trait for NonZero where T: ZeroablePrimitive + $Trait {} impl_nonzero_auto_trait!(UnwindSafe); #[stable(feature = "nonzero", since = "1.28.0")] -impl Clone for NonZero +#[rustc_const_unstable(feature = "const_clone", issue = "142757")] +impl const Clone for NonZero where T: ZeroablePrimitive, { @@ -202,7 +203,8 @@ impl Copy for NonZero where T: ZeroablePrimitive {} #[doc(hidden)] #[unstable(feature = "trivial_clone", issue = "none")] -unsafe impl TrivialClone for NonZero where T: ZeroablePrimitive {} +#[rustc_const_unstable(feature = "const_clone", issue = "142757")] +unsafe impl const TrivialClone for NonZero where T: ZeroablePrimitive {} #[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]