@@ -1943,15 +1943,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1943
1943
self . infcx . shallow_resolve ( substs. as_generator ( ) . tupled_upvars_ty ( ) ) ;
1944
1944
let resolved_witness =
1945
1945
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 ( ) {
1950
1947
// Not yet resolved.
1951
1948
Ambiguous
1952
1949
} 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 < _ > > ( ) ;
1955
1955
Where ( obligation. predicate . rebind ( all) )
1956
1956
}
1957
1957
} else {
@@ -1961,31 +1961,17 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1961
1961
1962
1962
ty:: GeneratorWitness ( binder) => {
1963
1963
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 ;
1987
1968
}
1988
1969
}
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) )
1989
1975
}
1990
1976
1991
1977
ty:: Closure ( _, substs) => {
0 commit comments