Skip to content

Commit dfcfca2

Browse files
committed
Take out an insurance policy in case iter.size_hint()
lies, underreporting the number of elements.
1 parent 23f890f commit dfcfca2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/librustc/ty/context.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -2930,14 +2930,18 @@ impl<T, R, E> InternIteratorElement<T, R> for Result<T, E> {
29302930
// lower bounds from `size_hint` agree they are correct.
29312931
Ok(match iter.size_hint() {
29322932
(1, Some(1)) => {
2933-
f(&[iter.next().unwrap()?])
2933+
let t0 = iter.next().unwrap()?;
2934+
assert!(iter.next().is_none());
2935+
f(&[t0])
29342936
}
29352937
(2, Some(2)) => {
29362938
let t0 = iter.next().unwrap()?;
29372939
let t1 = iter.next().unwrap()?;
2940+
assert!(iter.next().is_none());
29382941
f(&[t0, t1])
29392942
}
29402943
(0, Some(0)) => {
2944+
assert!(iter.next().is_none());
29412945
f(&[])
29422946
}
29432947
_ => {

0 commit comments

Comments
 (0)