Skip to content

Commit

Permalink
Rollup merge of rust-lang#22299 - bluss:range-64-is-not-exact-size, r…
Browse files Browse the repository at this point in the history
…=alexcrichton

 Fixes rust-lang#22047

`Range<u64>` and `Range<i64>` may be longer than usize::MAX on 32-bit
platforms, and thus they cannot fulfill the protocol for
ExactSizeIterator. We don't want a nonobvious platform dependency in
basic iterator traits, so the trait impl is removed.

The logic of this change assumes that usize is at least 32-bit.

This is technically a breaking change; note that `Range<usize>` and
`Range<isize>` are always ExactSizeIterators.

[breaking-change]
  • Loading branch information
Manishearth committed Feb 15, 2015
2 parents 0f66e31 + b19fda0 commit 1b86ebe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2676,9 +2676,9 @@ impl<A: Int> Iterator for ::ops::Range<A> {
}
}

// Ranges of u64 and i64 are excluded because they cannot guarantee having
// a length <= usize::MAX, which is required by ExactSizeIterator.
range_exact_iter_impl!(usize u8 u16 u32 isize i8 i16 i32);
#[cfg(target_pointer_width = "64")]
range_exact_iter_impl!(u64 i64);

#[stable(feature = "rust1", since = "1.0.0")]
impl<A: Int> DoubleEndedIterator for ::ops::Range<A> {
Expand Down

0 comments on commit 1b86ebe

Please sign in to comment.