Auto merge of #104731 - compiler-errors:early-binder-iter-size-hint, r=cjgillot

Add size hints to early binder iterator adapters

probably doesn't do anything, but definitely doesn't hurt
This commit is contained in:
bors 2022-11-26 14:59:30 +00:00
commit c3a1c023c0

View File

@ -589,6 +589,10 @@ impl<'tcx, I: IntoIterator> Iterator for SubstIter<'_, 'tcx, I>
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
Some(EarlyBinder(self.it.next()?).subst(self.tcx, self.substs)) Some(EarlyBinder(self.it.next()?).subst(self.tcx, self.substs))
} }
fn size_hint(&self) -> (usize, Option<usize>) {
self.it.size_hint()
}
} }
impl<'tcx, I: IntoIterator> DoubleEndedIterator for SubstIter<'_, 'tcx, I> impl<'tcx, I: IntoIterator> DoubleEndedIterator for SubstIter<'_, 'tcx, I>
@ -631,6 +635,10 @@ impl<'tcx, I: IntoIterator> Iterator for SubstIterCopied<'_, 'tcx, I>
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
Some(EarlyBinder(*self.it.next()?).subst(self.tcx, self.substs)) Some(EarlyBinder(*self.it.next()?).subst(self.tcx, self.substs))
} }
fn size_hint(&self) -> (usize, Option<usize>) {
self.it.size_hint()
}
} }
impl<'tcx, I: IntoIterator> DoubleEndedIterator for SubstIterCopied<'_, 'tcx, I> impl<'tcx, I: IntoIterator> DoubleEndedIterator for SubstIterCopied<'_, 'tcx, I>
@ -660,6 +668,10 @@ impl<T: Iterator> Iterator for EarlyBinderIter<T> {
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
self.t.next().map(|i| EarlyBinder(i)) self.t.next().map(|i| EarlyBinder(i))
} }
fn size_hint(&self) -> (usize, Option<usize>) {
self.t.size_hint()
}
} }
impl<'tcx, T: TypeFoldable<'tcx>> ty::EarlyBinder<T> { impl<'tcx, T: TypeFoldable<'tcx>> ty::EarlyBinder<T> {