@@ -441,7 +441,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
441441
442442 for required_region in required_region_bounds {
443443 concrete_ty. visit_with ( & mut ConstrainOpaqueTypeRegionVisitor {
444- infcx : self ,
445444 op : |r| self . sub_regions ( infer:: CallReturn ( span) , required_region, r) ,
446445 } ) ;
447446 }
@@ -510,7 +509,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
510509 }
511510 }
512511 concrete_ty. visit_with ( & mut ConstrainOpaqueTypeRegionVisitor {
513- infcx : self ,
514512 op : |r| self . sub_regions ( infer:: CallReturn ( span) , least_region, r) ,
515513 } ) ;
516514 }
@@ -545,7 +543,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
545543 ) ;
546544
547545 concrete_ty. visit_with ( & mut ConstrainOpaqueTypeRegionVisitor {
548- infcx : self ,
549546 op : |r| {
550547 self . member_constraint (
551548 opaque_type_def_id,
@@ -686,12 +683,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
686683//
687684// We ignore any type parameters because impl trait values are assumed to
688685// capture all the in-scope type parameters.
689- struct ConstrainOpaqueTypeRegionVisitor < ' cx , ' tcx , OP > {
690- infcx : & ' cx InferCtxt < ' cx , ' tcx > ,
686+ struct ConstrainOpaqueTypeRegionVisitor < OP > {
691687 op : OP ,
692688}
693689
694- impl < ' cx , ' tcx , OP > TypeVisitor < ' tcx > for ConstrainOpaqueTypeRegionVisitor < ' cx , ' tcx , OP >
690+ impl < ' tcx , OP > TypeVisitor < ' tcx > for ConstrainOpaqueTypeRegionVisitor < OP >
695691where
696692 OP : FnMut ( ty:: Region < ' tcx > ) ,
697693{
@@ -721,36 +717,28 @@ where
721717 ty:: Closure ( _, ref substs) => {
722718 // Skip lifetime parameters of the enclosing item(s)
723719
724- let ty = self . infcx . shallow_resolve ( substs. as_closure ( ) . tupled_upvars_ty ( ) ) ;
725- if let ty:: Infer ( ty:: TyVar ( _) ) = ty. kind ( ) {
726- // Not yet resolved.
727- ty. super_visit_with ( self ) ;
728- } else {
729- for upvar_ty in substs. as_closure ( ) . upvar_tys ( ) {
730- upvar_ty. visit_with ( self ) ;
731- }
720+ substs. as_closure ( ) . tupled_upvars_ty ( ) . visit_with ( self ) ;
732721
733- substs. as_closure ( ) . sig_as_fn_ptr_ty ( ) . visit_with ( self ) ;
722+ for upvar_ty in substs. as_closure ( ) . upvar_tys ( ) {
723+ upvar_ty. visit_with ( self ) ;
734724 }
725+
726+ substs. as_closure ( ) . sig_as_fn_ptr_ty ( ) . visit_with ( self ) ;
735727 }
736728
737729 ty:: Generator ( _, ref substs, _) => {
738730 // Skip lifetime parameters of the enclosing item(s)
739731 // Also skip the witness type, because that has no free regions.
740732
741- let ty = self . infcx . shallow_resolve ( substs. as_generator ( ) . tupled_upvars_ty ( ) ) ;
742- if let ty:: Infer ( ty:: TyVar ( _) ) = ty. kind ( ) {
743- // Not yet resolved.
744- ty. super_visit_with ( self ) ;
745- } else {
746- for upvar_ty in substs. as_generator ( ) . upvar_tys ( ) {
747- upvar_ty. visit_with ( self ) ;
748- }
733+ substs. as_generator ( ) . tupled_upvars_ty ( ) . visit_with ( self ) ;
749734
750- substs. as_generator ( ) . return_ty ( ) . visit_with ( self ) ;
751- substs. as_generator ( ) . yield_ty ( ) . visit_with ( self ) ;
752- substs. as_generator ( ) . resume_ty ( ) . visit_with ( self ) ;
735+ for upvar_ty in substs. as_generator ( ) . upvar_tys ( ) {
736+ upvar_ty. visit_with ( self ) ;
753737 }
738+
739+ substs. as_generator ( ) . return_ty ( ) . visit_with ( self ) ;
740+ substs. as_generator ( ) . yield_ty ( ) . visit_with ( self ) ;
741+ substs. as_generator ( ) . resume_ty ( ) . visit_with ( self ) ;
754742 }
755743 _ => {
756744 ty. super_visit_with ( self ) ;
0 commit comments