Skip to content

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

Open
jalil-salame wants to merge 8 commits intorust-lang:mainfrom
jalil-salame:nonzero-uint-step
Open

feat(core): impl Step for NonZero<u*>#127534
jalil-salame wants to merge 8 commits intorust-lang:mainfrom
jalil-salame:nonzero-uint-step

Conversation

@jalil-salame
Copy link
Contributor

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

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
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
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
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
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
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
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
Contributor Author

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

@joshtriplett
Copy link
Member

r? libs-api

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

Amanieu commented Nov 13, 2024

@rfcbot fcp merge

@rfcbot
Copy link

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

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
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Apr 30, 2025
@programmerjake
Copy link
Member

@jalil-salame I ran into code where I wanted this again today, do you have time/motivation to get this PR ready for merging anytime soon?

@rustbot
Copy link
Collaborator

rustbot commented Jan 2, 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.

@rust-log-analyzer

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>
As per review comment

Signed-off-by: Jalil David Salamé Messina <jalil.salame@gmail.com>
Signed-off-by: Jalil David Salamé Messina <jalil.salame@gmail.com>
`NonZero<u16>` and `NonZero<usize>` can safely implement
`ExactSizeIterator` for `RangeInclussive`

Signed-off-by: Jalil David Salamé Messina <jalil.salame@gmail.com>
Small doc change
Specially around the limits

Signed-off-by: Jalil David Salamé Messina <jalil.salame@gmail.com>
Copy link
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
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
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

jalil-salame and others added 2 commits January 6, 2026 10:35
Thanks @programmerjake

Signed-off-by: Jalil David Salamé Messina <jalil.salame@gmail.com>
This time for sure
@Amanieu Amanieu removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Jan 7, 2026
@Amanieu
Copy link
Member

Amanieu commented Jan 7, 2026

LGTM from the libs-api side.

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-review Status: Awaiting review from the assignee but also interested parties. 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.