Skip to content

Commit 256335b

Browse files
committed
Take out an insurance policy in case iter.size_hint()
lies, underreporting the number of elements.
1 parent 4a8c5b2 commit 256335b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/librustc/ty/context.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2867,14 +2867,18 @@ impl<T, R, E> InternIteratorElement<T, R> for Result<T, E> {
28672867
// lower bounds from `size_hint` agree they are correct.
28682868
Ok(match iter.size_hint() {
28692869
(1, Some(1)) => {
2870-
f(&[iter.next().unwrap()?])
2870+
let t0 = iter.next().unwrap()?;
2871+
assert!(iter.next().is_none());
2872+
f(&[t0])
28712873
}
28722874
(2, Some(2)) => {
28732875
let t0 = iter.next().unwrap()?;
28742876
let t1 = iter.next().unwrap()?;
2877+
assert!(iter.next().is_none());
28752878
f(&[t0, t1])
28762879
}
28772880
(0, Some(0)) => {
2881+
assert!(iter.next().is_none());
28782882
f(&[])
28792883
}
28802884
_ => {

0 commit comments

Comments
 (0)