@@ -296,15 +296,13 @@ impl<'tcx> ClosureArgs<'tcx> {
296
296
/// In case there was a type error in figuring out the types of the captured path, an
297
297
/// empty iterator is returned.
298
298
#[ inline]
299
- pub fn upvar_tys ( self ) -> impl Iterator < Item = Ty < ' tcx > > + ' tcx {
299
+ pub fn upvar_tys ( self ) -> & ' tcx List < Ty < ' tcx > > {
300
300
match self . tupled_upvars_ty ( ) . kind ( ) {
301
- TyKind :: Error ( _) => None ,
302
- TyKind :: Tuple ( ..) => Some ( self . tupled_upvars_ty ( ) . tuple_fields ( ) ) ,
301
+ TyKind :: Error ( _) => ty :: List :: empty ( ) ,
302
+ TyKind :: Tuple ( ..) => self . tupled_upvars_ty ( ) . tuple_fields ( ) ,
303
303
TyKind :: Infer ( _) => bug ! ( "upvar_tys called before capture types are inferred" ) ,
304
304
ty => bug ! ( "Unexpected representation of upvar types tuple {:?}" , ty) ,
305
305
}
306
- . into_iter ( )
307
- . flatten ( )
308
306
}
309
307
310
308
/// Returns the tuple type representing the upvars for this closure.
@@ -436,15 +434,13 @@ impl<'tcx> GeneratorArgs<'tcx> {
436
434
/// In case there was a type error in figuring out the types of the captured path, an
437
435
/// empty iterator is returned.
438
436
#[ inline]
439
- pub fn upvar_tys ( self ) -> impl Iterator < Item = Ty < ' tcx > > + ' tcx {
437
+ pub fn upvar_tys ( self ) -> & ' tcx List < Ty < ' tcx > > {
440
438
match self . tupled_upvars_ty ( ) . kind ( ) {
441
- TyKind :: Error ( _) => None ,
442
- TyKind :: Tuple ( ..) => Some ( self . tupled_upvars_ty ( ) . tuple_fields ( ) ) ,
439
+ TyKind :: Error ( _) => ty :: List :: empty ( ) ,
440
+ TyKind :: Tuple ( ..) => self . tupled_upvars_ty ( ) . tuple_fields ( ) ,
443
441
TyKind :: Infer ( _) => bug ! ( "upvar_tys called before capture types are inferred" ) ,
444
442
ty => bug ! ( "Unexpected representation of upvar types tuple {:?}" , ty) ,
445
443
}
446
- . into_iter ( )
447
- . flatten ( )
448
444
}
449
445
450
446
/// Returns the tuple type representing the upvars for this generator.
@@ -576,7 +572,7 @@ impl<'tcx> GeneratorArgs<'tcx> {
576
572
/// This is the types of the fields of a generator which are not stored in a
577
573
/// variant.
578
574
#[ inline]
579
- pub fn prefix_tys ( self ) -> impl Iterator < Item = Ty < ' tcx > > {
575
+ pub fn prefix_tys ( self ) -> & ' tcx List < Ty < ' tcx > > {
580
576
self . upvar_tys ( )
581
577
}
582
578
}
@@ -592,20 +588,18 @@ impl<'tcx> UpvarArgs<'tcx> {
592
588
/// In case there was a type error in figuring out the types of the captured path, an
593
589
/// empty iterator is returned.
594
590
#[ inline]
595
- pub fn upvar_tys ( self ) -> impl Iterator < Item = Ty < ' tcx > > + ' tcx {
591
+ pub fn upvar_tys ( self ) -> & ' tcx List < Ty < ' tcx > > {
596
592
let tupled_tys = match self {
597
593
UpvarArgs :: Closure ( args) => args. as_closure ( ) . tupled_upvars_ty ( ) ,
598
594
UpvarArgs :: Generator ( args) => args. as_generator ( ) . tupled_upvars_ty ( ) ,
599
595
} ;
600
596
601
597
match tupled_tys. kind ( ) {
602
- TyKind :: Error ( _) => None ,
603
- TyKind :: Tuple ( ..) => Some ( self . tupled_upvars_ty ( ) . tuple_fields ( ) ) ,
598
+ TyKind :: Error ( _) => ty :: List :: empty ( ) ,
599
+ TyKind :: Tuple ( ..) => self . tupled_upvars_ty ( ) . tuple_fields ( ) ,
604
600
TyKind :: Infer ( _) => bug ! ( "upvar_tys called before capture types are inferred" ) ,
605
601
ty => bug ! ( "Unexpected representation of upvar types tuple {:?}" , ty) ,
606
602
}
607
- . into_iter ( )
608
- . flatten ( )
609
603
}
610
604
611
605
#[ inline]
0 commit comments