Skip to content

Commit eee2d04

Browse files
authored
Auto merge of #36395 - durka:rangeinclusive-no-esi, r=alexcrichton
remove ExactSizeIterator from RangeInclusive<{u,i}{32,size}> Fixes #36386. This is a [breaking-change] for nightly users of `#![feature(inclusive_range_syntax)]` and/or `#![feature(inclusive_range)]`.
2 parents 86affcd + bd1ae63 commit eee2d04

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/libcore/iter/range.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,11 @@ macro_rules! range_exact_iter_impl {
466466
($($t:ty)*) => ($(
467467
#[stable(feature = "rust1", since = "1.0.0")]
468468
impl ExactSizeIterator for ops::Range<$t> { }
469+
)*)
470+
}
469471

472+
macro_rules! range_incl_exact_iter_impl {
473+
($($t:ty)*) => ($(
470474
#[unstable(feature = "inclusive_range",
471475
reason = "recently added, follows RFC",
472476
issue = "28237")]
@@ -500,9 +504,12 @@ impl<A: Step> Iterator for ops::Range<A> where
500504
}
501505
}
502506

503-
// Ranges of u64 and i64 are excluded because they cannot guarantee having
504-
// a length <= usize::MAX, which is required by ExactSizeIterator.
507+
// These macros generate `ExactSizeIterator` impls for various range types.
508+
// Range<{u,i}64> and RangeInclusive<{u,i}{32,64,size}> are excluded
509+
// because they cannot guarantee having a length <= usize::MAX, which is
510+
// required by ExactSizeIterator.
505511
range_exact_iter_impl!(usize u8 u16 u32 isize i8 i16 i32);
512+
range_incl_exact_iter_impl!(u8 u16 i8 i16);
506513

507514
#[stable(feature = "rust1", since = "1.0.0")]
508515
impl<A: Step + Clone> DoubleEndedIterator for ops::Range<A> where

src/test/run-pass/range_inclusive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub fn main() {
7575

7676
// test the size hints and emptying
7777
let mut long = 0...255u8;
78-
let mut short = 42...42;
78+
let mut short = 42...42u8;
7979
assert_eq!(long.size_hint(), (256, Some(256)));
8080
assert_eq!(short.size_hint(), (1, Some(1)));
8181
long.next();

0 commit comments

Comments
 (0)