@@ -345,7 +345,7 @@ impl<'tcx> ClosureSubsts<'tcx> {
345345 self ,
346346 def_id : DefId ,
347347 tcx : TyCtxt < ' _ > ,
348- ) -> impl Iterator < Item = Ty < ' tcx > > + ' tcx {
348+ ) -> impl Iterator < Item = Ty < ' tcx > > + ExactSizeIterator + ' tcx {
349349 let SplitClosureSubsts { upvar_kinds, .. } = self . split ( def_id, tcx) ;
350350 upvar_kinds. iter ( ) . map ( |t| {
351351 if let GenericArgKind :: Type ( ty) = t. unpack ( ) {
@@ -433,7 +433,7 @@ impl<'tcx> GeneratorSubsts<'tcx> {
433433 self ,
434434 def_id : DefId ,
435435 tcx : TyCtxt < ' _ > ,
436- ) -> impl Iterator < Item = Ty < ' tcx > > + ' tcx {
436+ ) -> impl Iterator < Item = Ty < ' tcx > > + ExactSizeIterator + ' tcx {
437437 let SplitGeneratorSubsts { upvar_kinds, .. } = self . split ( def_id, tcx) ;
438438 upvar_kinds. iter ( ) . map ( |t| {
439439 if let GenericArgKind :: Type ( ty) = t. unpack ( ) {
@@ -551,7 +551,7 @@ impl<'tcx> GeneratorSubsts<'tcx> {
551551 self ,
552552 def_id : DefId ,
553553 tcx : TyCtxt < ' tcx > ,
554- ) -> impl Iterator < Item = impl Iterator < Item = Ty < ' tcx > > + Captures < ' tcx > > {
554+ ) -> impl Iterator < Item = impl Iterator < Item = Ty < ' tcx > > + ExactSizeIterator + Captures < ' tcx > > {
555555 let layout = tcx. generator_layout ( def_id) ;
556556 layout. variant_fields . iter ( ) . map ( move |variant| {
557557 variant. iter ( ) . map ( move |field| {
@@ -563,7 +563,9 @@ impl<'tcx> GeneratorSubsts<'tcx> {
563563 /// This is the types of the fields of a generator which are not stored in a
564564 /// variant.
565565 #[ inline]
566- pub fn prefix_tys ( self , def_id : DefId , tcx : TyCtxt < ' tcx > ) -> impl Iterator < Item = Ty < ' tcx > > {
566+ pub fn prefix_tys ( self , def_id : DefId , tcx : TyCtxt < ' tcx > )
567+ -> impl Iterator < Item = Ty < ' tcx > > + ExactSizeIterator
568+ {
567569 self . upvar_tys ( def_id, tcx)
568570 }
569571}
@@ -580,7 +582,7 @@ impl<'tcx> UpvarSubsts<'tcx> {
580582 self ,
581583 def_id : DefId ,
582584 tcx : TyCtxt < ' tcx > ,
583- ) -> impl Iterator < Item = Ty < ' tcx > > + ' tcx {
585+ ) -> impl Iterator < Item = Ty < ' tcx > > + ExactSizeIterator + ' tcx {
584586 let upvar_kinds = match self {
585587 UpvarSubsts :: Closure ( substs) => substs. as_closure ( ) . split ( def_id, tcx) . upvar_kinds ,
586588 UpvarSubsts :: Generator ( substs) => substs. as_generator ( ) . split ( def_id, tcx) . upvar_kinds ,
0 commit comments