]> git.lizzy.rs Git - rust.git/commit
Auto merge of #24865 - bluss:range-size, r=alexcrichton
authorbors <bors@rust-lang.org>
Wed, 29 Apr 2015 00:15:22 +0000 (00:15 +0000)
committerbors <bors@rust-lang.org>
Wed, 29 Apr 2015 00:15:22 +0000 (00:15 +0000)
commitc4b23aec4c5ddf32df1e0ba3cc23212327cd8b1f
tree45cf093827a54610239c2fddd3760b8addf4444d
parent8871c17b76a1e0ab36ce2bb51008b53f596e5b3c
parent95be21df477655131627def1943de73922b1f6a4
Auto merge of #24865 - bluss:range-size, r=alexcrichton

core: Fix size_hint for signed integer `Range<T>` iterators

There was an overflow bug in .size_hint() for signed iterators, which
produced an hilariously incorrect size or an overflow panic.

Incorrect size is a serious bug since the iterators are marked
ExactSizeIterator. (And leads to abort() on (-1i8..127).collect() when
the collection tries to preallocate too much).

> (-1i8..127).size_hint()
(18446744073709551488, Some(18446744073709551488))

Bug found using quickcheck.

Fixes #24851
src/libcore/iter.rs