]> git.lizzy.rs Git - rust.git/commitdiff
Remove ExactSizeIterator from 64-bit ranges.
authorUlrik Sverdrup <root@localhost>
Fri, 13 Feb 2015 20:20:16 +0000 (21:20 +0100)
committerUlrik Sverdrup <root@localhost>
Fri, 13 Feb 2015 20:26:50 +0000 (21:26 +0100)
Fixes #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]

src/libcore/iter.rs

index 7740cd6867cbd2707d96719ee8e1d7b7f7034edf..06aba2cb08ef34df8039c868ab5309d8251a644f 100644 (file)
@@ -2676,9 +2676,9 @@ fn size_hint(&self) -> (usize, Option<usize>) {
     }
 }
 
+// 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> {