Rollup merge of #154825 - Lars-Schumann:non-zero-const-step, r=jhpratt

constify `Step for NonZero<u*>`

Tracking Issue: https://github.com/rust-lang/rust/issues/42168

I missed the constification of `Step for NonZero<u*>` in the recent https://github.com/rust-lang/rust/pull/153821, so here they are.

Had to constify the `Clone` / `TrivialClone` impls along the way https://github.com/rust-lang/rust/issues/142757 .
This commit is contained in:
Jonathan Brouwer
2026-04-07 17:26:33 +02:00
committed by GitHub
2 changed files with 8 additions and 4 deletions
+4 -2
View File
@@ -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<Self> {
$(
#[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]
+4 -2
View File
@@ -184,7 +184,8 @@ impl<T> $Trait for NonZero<T> where T: ZeroablePrimitive + $Trait {}
impl_nonzero_auto_trait!(UnwindSafe);
#[stable(feature = "nonzero", since = "1.28.0")]
impl<T> Clone for NonZero<T>
#[rustc_const_unstable(feature = "const_clone", issue = "142757")]
impl<T> const Clone for NonZero<T>
where
T: ZeroablePrimitive,
{
@@ -202,7 +203,8 @@ impl<T> Copy for NonZero<T> where T: ZeroablePrimitive {}
#[doc(hidden)]
#[unstable(feature = "trivial_clone", issue = "none")]
unsafe impl<T> TrivialClone for NonZero<T> where T: ZeroablePrimitive {}
#[rustc_const_unstable(feature = "const_clone", issue = "142757")]
unsafe impl<T> const TrivialClone for NonZero<T> where T: ZeroablePrimitive {}
#[stable(feature = "nonzero", since = "1.28.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]