Skip to content

Commit f89168e

Browse files
committed
Rollup merge of rust-lang#22299 - bluss:range-64-is-not-exact-size, r=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]
2 parents a3a1f86 + b19fda0 commit f89168e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libcore/iter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,9 +2676,9 @@ impl<A: Int> Iterator for ::ops::Range<A> {
26762676
}
26772677
}
26782678

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

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

0 commit comments

Comments
 (0)