@@ -1943,15 +1943,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
19431943 self . infcx . shallow_resolve ( substs. as_generator ( ) . tupled_upvars_ty ( ) ) ;
19441944 let resolved_witness =
19451945 self . infcx . shallow_resolve ( substs. as_generator ( ) . witness ( ) ) ;
1946- if {
1947- matches ! ( resolved_upvars. kind( ) , ty:: Infer ( ty:: TyVar ( _) ) )
1948- || matches ! ( resolved_witness. kind( ) , ty:: Infer ( ty:: TyVar ( _) ) )
1949- } {
1946+ if resolved_upvars. is_ty_var ( ) || resolved_witness. is_ty_var ( ) {
19501947 // Not yet resolved.
19511948 Ambiguous
19521949 } else {
1953- let mut all = substs. as_generator ( ) . upvar_tys ( ) . collect :: < Vec < _ > > ( ) ;
1954- all. push ( substs. as_generator ( ) . witness ( ) ) ;
1950+ let all = substs
1951+ . as_generator ( )
1952+ . upvar_tys ( )
1953+ . chain ( iter:: once ( substs. as_generator ( ) . witness ( ) ) )
1954+ . collect :: < Vec < _ > > ( ) ;
19551955 Where ( obligation. predicate . rebind ( all) )
19561956 }
19571957 } else {
@@ -1961,31 +1961,17 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
19611961
19621962 ty:: GeneratorWitness ( binder) => {
19631963 let witness_tys = binder. skip_binder ( ) ;
1964- let mut iter = witness_tys. iter ( ) ;
1965- loop {
1966- match iter. next ( ) {
1967- Some ( witness_ty) => {
1968- let resolved = self . infcx . shallow_resolve ( witness_ty) ;
1969- if matches ! ( resolved. kind( ) , ty:: Infer ( ty:: TyVar ( _) ) ) {
1970- break Ambiguous ;
1971- }
1972- }
1973- Option :: None => {
1974- // (*) binder moved here
1975- let all_vars = self . tcx ( ) . mk_bound_variable_kinds (
1976- obligation
1977- . predicate
1978- . bound_vars ( )
1979- . iter ( )
1980- . chain ( binder. bound_vars ( ) . iter ( ) ) ,
1981- ) ;
1982- break Where ( ty:: Binder :: bind_with_vars (
1983- witness_tys. to_vec ( ) ,
1984- all_vars,
1985- ) ) ;
1986- }
1964+ for witness_ty in witness_tys. iter ( ) {
1965+ let resolved = self . infcx . shallow_resolve ( witness_ty) ;
1966+ if resolved. is_ty_var ( ) {
1967+ return Ambiguous ;
19871968 }
19881969 }
1970+ // (*) binder moved here
1971+ let all_vars = self . tcx ( ) . mk_bound_variable_kinds (
1972+ obligation. predicate . bound_vars ( ) . iter ( ) . chain ( binder. bound_vars ( ) . iter ( ) ) ,
1973+ ) ;
1974+ Where ( ty:: Binder :: bind_with_vars ( witness_tys. to_vec ( ) , all_vars) )
19891975 }
19901976
19911977 ty:: Closure ( _, substs) => {
0 commit comments