diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-24 03:21:23 +0200 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-25 17:43:53 +0200 |
| commit | dfcfca28ad1321aff82503ebfffd40cf6476a7a2 (patch) | |
| tree | 4036d3441af44495d1527ea1a59a33611bfae116 /src | |
| parent | 23f890f10202a71168c6424da0cdf94135d3c40c (diff) | |
| download | rust-dfcfca28ad1321aff82503ebfffd40cf6476a7a2.tar.gz rust-dfcfca28ad1321aff82503ebfffd40cf6476a7a2.zip | |
Take out an insurance policy in case `iter.size_hint()`
lies, underreporting the number of elements.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/ty/context.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index f958a7e357b..0f7d5d9a25e 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -2930,14 +2930,18 @@ impl<T, R, E> InternIteratorElement<T, R> for Result<T, E> { // lower bounds from `size_hint` agree they are correct. Ok(match iter.size_hint() { (1, Some(1)) => { - f(&[iter.next().unwrap()?]) + let t0 = iter.next().unwrap()?; + assert!(iter.next().is_none()); + f(&[t0]) } (2, Some(2)) => { let t0 = iter.next().unwrap()?; let t1 = iter.next().unwrap()?; + assert!(iter.next().is_none()); f(&[t0, t1]) } (0, Some(0)) => { + assert!(iter.next().is_none()); f(&[]) } _ => { |
