Skip to content

Commit 4399b9e

Browse files
committed
Auto merge of rust-lang#124910 - matthiaskrgr:rollup-lo1uvdn, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#123344 (Remove braces when fixing a nested use tree into a single item) - rust-lang#124587 (Generic `NonZero` post-stabilization changes.) - rust-lang#124775 (crashes: add lastest batch of crash tests) - rust-lang#124869 (Make sure we don't deny macro vars w keyword names) - rust-lang#124876 (Simplify `use crate::rustc_foo::bar` occurrences.) - rust-lang#124892 (Update cc crate to v1.0.97) - rust-lang#124903 (Ignore empty RUSTC_WRAPPER in bootstrap) - rust-lang#124909 (Reapply the part of rust-lang#124548 that bors forgot) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 19ae86b + a7f8f81 commit 4399b9e

File tree

3 files changed

+187
-189
lines changed

3 files changed

+187
-189
lines changed

core/src/iter/adapters/step_by.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
intrinsics,
33
iter::{from_fn, TrustedLen, TrustedRandomAccess},
4-
num::NonZeroUsize,
4+
num::NonZero,
55
ops::{Range, Try},
66
};
77

@@ -42,10 +42,10 @@ impl<I> StepBy<I> {
4242
/// The `step` that was originally passed to `Iterator::step_by(step)`,
4343
/// aka `self.step_minus_one + 1`.
4444
#[inline]
45-
fn original_step(&self) -> NonZeroUsize {
45+
fn original_step(&self) -> NonZero<usize> {
4646
// SAFETY: By type invariant, `step_minus_one` cannot be `MAX`, which
4747
// means the addition cannot overflow and the result cannot be zero.
48-
unsafe { NonZeroUsize::new_unchecked(intrinsics::unchecked_add(self.step_minus_one, 1)) }
48+
unsafe { NonZero::new_unchecked(intrinsics::unchecked_add(self.step_minus_one, 1)) }
4949
}
5050
}
5151

@@ -231,12 +231,12 @@ unsafe impl<I: Iterator> StepByImpl<I> for StepBy<I> {
231231
#[inline]
232232
default fn spec_size_hint(&self) -> (usize, Option<usize>) {
233233
#[inline]
234-
fn first_size(step: NonZeroUsize) -> impl Fn(usize) -> usize {
234+
fn first_size(step: NonZero<usize>) -> impl Fn(usize) -> usize {
235235
move |n| if n == 0 { 0 } else { 1 + (n - 1) / step }
236236
}
237237

238238
#[inline]
239-
fn other_size(step: NonZeroUsize) -> impl Fn(usize) -> usize {
239+
fn other_size(step: NonZero<usize>) -> impl Fn(usize) -> usize {
240240
move |n| n / step
241241
}
242242

0 commit comments

Comments
 (0)