Skip to content

Add size hints to early binder iterator adapters #104731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions compiler/rustc_middle/src/ty/subst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,10 @@ where
fn next(&mut self) -> Option<Self::Item> {
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>
Expand Down Expand Up @@ -631,6 +635,10 @@ where
fn next(&mut self) -> Option<Self::Item> {
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>
Expand Down Expand Up @@ -660,6 +668,10 @@ impl<T: Iterator> Iterator for EarlyBinderIter<T> {
fn next(&mut self) -> Option<Self::Item> {
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> {
Expand Down