From 0ba5e7416ffca2de7d328d0bcbd0321ab790edb3 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 22 Nov 2022 18:35:41 +0000 Subject: [PATCH] Add size hints to early binder iterator adapters --- compiler/rustc_middle/src/ty/subst.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/compiler/rustc_middle/src/ty/subst.rs b/compiler/rustc_middle/src/ty/subst.rs index c1cf7896db5..d8c1c63d7a3 100644 --- a/compiler/rustc_middle/src/ty/subst.rs +++ b/compiler/rustc_middle/src/ty/subst.rs @@ -589,6 +589,10 @@ where fn next(&mut self) -> Option { Some(EarlyBinder(self.it.next()?).subst(self.tcx, self.substs)) } + + fn size_hint(&self) -> (usize, Option) { + self.it.size_hint() + } } impl<'tcx, I: IntoIterator> DoubleEndedIterator for SubstIter<'_, 'tcx, I> @@ -631,6 +635,10 @@ where fn next(&mut self) -> Option { Some(EarlyBinder(*self.it.next()?).subst(self.tcx, self.substs)) } + + fn size_hint(&self) -> (usize, Option) { + self.it.size_hint() + } } impl<'tcx, I: IntoIterator> DoubleEndedIterator for SubstIterCopied<'_, 'tcx, I> @@ -660,6 +668,10 @@ impl Iterator for EarlyBinderIter { fn next(&mut self) -> Option { self.t.next().map(|i| EarlyBinder(i)) } + + fn size_hint(&self) -> (usize, Option) { + self.t.size_hint() + } } impl<'tcx, T: TypeFoldable<'tcx>> ty::EarlyBinder {