Skip to content

feat(core): impl Step for NonZero<u*>#127534

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
jalil-salame:nonzero-uint-step
Apr 4, 2026
Merged

feat(core): impl Step for NonZero<u*>#127534
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
jalil-salame:nonzero-uint-step

Conversation

@jalil-salame
Copy link
Copy Markdown
Contributor

@jalil-salame jalil-salame commented Jul 9, 2024

View all comments

Implement Step for NonZero unsigned integers as discussed in libs-team#130.

step_nonzero_impls was adapted from step_integer_impls and the tests were adapted from the step tests.

It seems to compile and pass the tests c:

I would like to test the edge cases, specially around overflows. To ensure safe code cannot generate a 0 NonZero, but I don't know how to go about it. I would love some feedback on that (and the PR overall).

The impls are tagges with #[unstable(feature = "step_trait", reason = "recently redesigned", issue = "42168")]. I assumed this was appropriate, but I am not sure.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jul 9, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @cuviper (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 9, 2024
@rust-log-analyzer

This comment has been minimized.

@jalil-salame
Copy link
Copy Markdown
Contributor Author

jalil-salame commented Jul 9, 2024

UI tests are failing because the output of diagnostics was reorganized now that NonZero<u*> implement Step. A preliminary look at the contribution docs (https://rustc-dev-guide.rust-lang.org/tests/ui.html#ui-tests) does not show how to update the test output.

Its getting late so I'll take a look at it tomorrow and see if I find a way to update the ui tests.

@cuviper
Copy link
Copy Markdown
Member

cuviper commented Jul 10, 2024

You can use ./x.py test --bless ui to update the expected output.

I know you already went through an ACP, but I think this still needs a libs-api reviewer since it is instantly stable -- Step is unstable, but it expands the stable impl<A> Iterator for Range<A> etc.

@rustbot label -T-libs +T-libs-api
r? libs-api

@rustbot rustbot added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 10, 2024
@rustbot rustbot assigned joshtriplett and unassigned cuviper Jul 10, 2024
Copy link
Copy Markdown
Member

@the8472 the8472 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the stable API surface: We should also add the appropriate ExactSizeIterator impls, without repeating the 16-bit-platform mistakes.

@jalil-salame
Copy link
Copy Markdown
Contributor Author

jalil-salame commented Jul 10, 2024

I'm having issues with the ui tests due to NixOS not having the library headers for rust-LLD in the right place. I'll see if I can fix later today. Apparently the failing tests were not preventing me from updating the ui tests 🤦

@jalil-salame
Copy link
Copy Markdown
Contributor Author

Regarding the stable API surface: We should also add the appropriate ExactSizeIterator impls, without repeating the 16-bit-platform mistakes.

I see that TrustedRandomAccess is cfg gated based on the pointer width but that is not the case for ExactSizeIterator for Range and RangeInclusive. See here. I assume that is because you don't want to implement a non-marker trait on types conditionally.

@jalil-salame
Copy link
Copy Markdown
Contributor Author

@joshtriplett friendly ping. Should I assign someone else if you are too busy?

@joshtriplett
Copy link
Copy Markdown
Member

r? libs-api

@rustbot rustbot assigned m-ou-se and unassigned joshtriplett Aug 26, 2024
@Amanieu
Copy link
Copy Markdown
Member

Amanieu commented Nov 13, 2024

@rfcbot fcp merge

@rfcbot
Copy link
Copy Markdown

rfcbot commented Nov 13, 2024

Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Nov 13, 2024
@rfcbot rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Feb 6, 2025
@rfcbot
Copy link
Copy Markdown

rfcbot commented Feb 6, 2025

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Feb 6, 2025
Copy link
Copy Markdown
Member

@programmerjake programmerjake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than this one comment fix, looks good

View changes since this review

@tgross35
Copy link
Copy Markdown
Contributor

tgross35 commented Jan 4, 2026

@rustbot label +I-libs-api-nominated

FCP completed for this change (#127534 (comment)) but that was about a year ago. I don't expect that anything changed, but re-nominating since it's been a while just to be sure.

@rustbot rustbot added the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Jan 4, 2026
Copy link
Copy Markdown
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me after Jake's request, and after a thumbs up from libs-api. Will need a squash before merge of course.

View changes since this review

@Amanieu Amanieu removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Jan 7, 2026
@Amanieu
Copy link
Copy Markdown
Member

Amanieu commented Jan 7, 2026

LGTM from the libs-api side.

@ArhanChaudhary
Copy link
Copy Markdown

From my understanding this is ready to be merged. Quick little bump :-)

@tgross35
Copy link
Copy Markdown
Contributor

tgross35 commented Apr 2, 2026

This still needs the squash I mentioned above, @jalil-salame could you do that?

@rustbot

This comment has been minimized.

Implement Step for NonZero unsigned integers as discussed in
[libs-team#130][1].

[1]: rust-lang/libs-team#130

`step_nonzero_impls` was adapted from `step_integer_impls` and the tests
were adapted from the step tests.

Signed-off-by: Jalil David Salamé Messina <jalil.salame@gmail.com>
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 3, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@tgross35
Copy link
Copy Markdown
Contributor

tgross35 commented Apr 3, 2026

@bors r=programmerjake,tgross35

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 3, 2026

📌 Commit d6b2806 has been approved by programmerjake,tgross35

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 3, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Apr 4, 2026
…programmerjake,tgross35

feat(core): impl Step for NonZero<u*>

Implement Step for NonZero unsigned integers as discussed in [libs-team#130][1].

[1]: rust-lang/libs-team#130

`step_nonzero_impls` was adapted from `step_integer_impls` and the tests were adapted from the step tests.

It seems to compile and pass the tests c:

I would like to test the edge cases, specially around overflows. To ensure safe code cannot generate a 0 `NonZero`, but I don't know how to go about it. I would love some feedback on that (and the PR overall).

The impls are tagges with `#[unstable(feature = "step_trait", reason = "recently redesigned", issue = "42168")]`. I assumed this was appropriate, but I am not sure.
rust-bors bot pushed a commit that referenced this pull request Apr 4, 2026
Rollup of 10 pull requests

Successful merges:

 - #154376 (Remove more BuiltinLintDiag variants - part 4)
 - #127534 (feat(core): impl Step for NonZero<u*>)
 - #153286 (various fixes for scalable vectors)
 - #153592 (Add  `min_adt_const_params` gate)
 - #154675 (Improve shadowed private field diagnostics)
 - #154703 (Fix trailing comma in lifetime suggestion for empty angle brackets)
 - #154653 (Remove rustc_on_unimplemented's append_const_msg)
 - #154743 (Remove an unused `StableHash` impl.)
 - #154752 (Add comment to borrow-checker)
 - #154764 (Add tests for three ICEs that have already been fixed)
rust-bors bot pushed a commit that referenced this pull request Apr 4, 2026
Rollup of 5 pull requests

Successful merges:

 - #154376 (Remove more BuiltinLintDiag variants - part 4)
 - #154731 (llvm: Fix array ABI test to not check equality implementation)
 - #127534 (feat(core): impl Step for NonZero<u*>)
 - #154703 (Fix trailing comma in lifetime suggestion for empty angle brackets)
 - #154776 (Fix ICE in read_discriminant for enums with non-contiguous discriminants)
@rust-bors rust-bors bot merged commit e923bac into rust-lang:main Apr 4, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Apr 4, 2026
rust-timer added a commit that referenced this pull request Apr 4, 2026
Rollup merge of #127534 - jalil-salame:nonzero-uint-step, r=programmerjake,tgross35

feat(core): impl Step for NonZero<u*>

Implement Step for NonZero unsigned integers as discussed in [libs-team#130][1].

[1]: rust-lang/libs-team#130

`step_nonzero_impls` was adapted from `step_integer_impls` and the tests were adapted from the step tests.

It seems to compile and pass the tests c:

I would like to test the edge cases, specially around overflows. To ensure safe code cannot generate a 0 `NonZero`, but I don't know how to go about it. I would love some feedback on that (and the PR overall).

The impls are tagges with `#[unstable(feature = "step_trait", reason = "recently redesigned", issue = "42168")]`. I assumed this was appropriate, but I am not sure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.