Skip to content

Conversation

@hkBst
Copy link
Member

@hkBst hkBst commented Dec 22, 2025

Continuation of #146436

r? @joboet

@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 Dec 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 22, 2025

r? @scottmcm

rustbot has assigned @scottmcm.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Copy link
Member

@Kivooeo Kivooeo left a comment

Choose a reason for hiding this comment

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

That seems like a good change to me, but unfortunately I can't r+ it since this is a library change

r? scottmcm

View changes since this review

@rustbot rustbot assigned scottmcm and unassigned Kivooeo Dec 22, 2025
Some(sum) => sum,
None => 0,
};
let start = end.checked_sub(self.chunk_size).unwrap_or_default();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let start = end.checked_sub(self.chunk_size).unwrap_or_default();
let start = end.saturating_sub(self.chunk_size);

wouldn't this be even better?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's correct, and I'm now using that.

@rustbot
Copy link
Collaborator

rustbot commented Dec 23, 2025

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.

@rustbot rustbot assigned joboet and unassigned scottmcm Dec 23, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 23, 2025

joboet is not on the review rotation at the moment.
They may take a while to respond.

@rust-log-analyzer

This comment has been minimized.

@hkBst hkBst changed the title replace match on unchecked_sub with unwrap_or_default slice iter cleanup: replace unchecked_sub with saturating_sub Dec 24, 2025
@hkBst hkBst changed the title slice iter cleanup: replace unchecked_sub with saturating_sub slice iter cleanup: replace checked_sub with saturating_sub Dec 24, 2025
@joboet
Copy link
Member

joboet commented Dec 29, 2025

Thanks!
@bors r+

@bors
Copy link
Collaborator

bors commented Dec 29, 2025

📌 Commit 16b219a has been approved by joboet

It is now in the queue for this repository.

@bors bors 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 Dec 29, 2025
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Dec 29, 2025
slice iter cleanup: replace checked_sub with saturating_sub

Continuation of rust-lang#146436

r? ``@joboet``
bors added a commit that referenced this pull request Dec 29, 2025
Rollup of 6 pull requests

Successful merges:

 - #150108 (Offload: Build offload as a single Step)
 - #150262 (slice iter cleanup: replace checked_sub with saturating_sub)
 - #150427 (add has_offload/needs-offload to the test infra)
 - #150458 (fix running stdlib doctests in Miri in CI)
 - #150477 (Fix enum variant suggestion consuming trailing parenthesis)
 - #150478 (Fix new bors config)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9de01a8 into rust-lang:main Dec 29, 2025
11 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Dec 29, 2025
rust-timer added a commit that referenced this pull request Dec 29, 2025
Rollup merge of #150262 - hkBst:slice-iter-2, r=joboet

slice iter cleanup: replace checked_sub with saturating_sub

Continuation of #146436

r? `@joboet`
// Therefore the bounds check in split_at_mut guarantees the split point is inbounds.
let (nth, _) = unsafe { tail.split_at_mut(end - start) };
self.v = head;
// SAFETY: The self.v contract ensures that any split_at_mut is valid.
Copy link
Member

Choose a reason for hiding this comment

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

Why did you change this line? It's not "cleanup" and it's also now wrong, because the contract is on self, not self.v.

(It makes it seem like you did this with AI without actually looking at the diff.)

Copy link
Member Author

Choose a reason for hiding this comment

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

No AI was involved.

I'm not sure I agree that this is wrong (or that it would be correct with self instead of self.v). The call to split_at_mut only puts a requirement on self.v; if self.v.len() is correct, then any split_at_mut call is safe. This could even become split_at_mut_unchecked since it is always in bounds due to let end = self.v.len() - end;

I do think the safety comment for the second call to split_at_mut is suboptimal, since the receiver is not self.v, but rest, but this problem is pre-existing.

github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Jan 2, 2026
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#150108 (Offload: Build offload as a single Step)
 - rust-lang/rust#150262 (slice iter cleanup: replace checked_sub with saturating_sub)
 - rust-lang/rust#150427 (add has_offload/needs-offload to the test infra)
 - rust-lang/rust#150458 (fix running stdlib doctests in Miri in CI)
 - rust-lang/rust#150477 (Fix enum variant suggestion consuming trailing parenthesis)
 - rust-lang/rust#150478 (Fix new bors config)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants