@@ -1902,15 +1902,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1902
1902
self . infcx . shallow_resolve ( substs. as_generator ( ) . tupled_upvars_ty ( ) ) ;
1903
1903
let resolved_witness =
1904
1904
self . infcx . shallow_resolve ( substs. as_generator ( ) . witness ( ) ) ;
1905
- if {
1906
- matches ! ( resolved_upvars. kind( ) , ty:: Infer ( ty:: TyVar ( _) ) )
1907
- || matches ! ( resolved_witness. kind( ) , ty:: Infer ( ty:: TyVar ( _) ) )
1908
- } {
1905
+ if resolved_upvars. is_ty_var ( ) || resolved_witness. is_ty_var ( ) {
1909
1906
// Not yet resolved.
1910
1907
Ambiguous
1911
1908
} else {
1912
- let mut all = substs. as_generator ( ) . upvar_tys ( ) . collect :: < Vec < _ > > ( ) ;
1913
- all. push ( substs. as_generator ( ) . witness ( ) ) ;
1909
+ let all = substs
1910
+ . as_generator ( )
1911
+ . upvar_tys ( )
1912
+ . chain ( iter:: once ( substs. as_generator ( ) . witness ( ) ) )
1913
+ . collect :: < Vec < _ > > ( ) ;
1914
1914
Where ( obligation. predicate . rebind ( all) )
1915
1915
}
1916
1916
} else {
@@ -1920,31 +1920,17 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1920
1920
1921
1921
ty:: GeneratorWitness ( binder) => {
1922
1922
let witness_tys = binder. skip_binder ( ) ;
1923
- let mut iter = witness_tys. iter ( ) ;
1924
- loop {
1925
- match iter. next ( ) {
1926
- Some ( witness_ty) => {
1927
- let resolved = self . infcx . shallow_resolve ( witness_ty) ;
1928
- if matches ! ( resolved. kind( ) , ty:: Infer ( ty:: TyVar ( _) ) ) {
1929
- break Ambiguous ;
1930
- }
1931
- }
1932
- Option :: None => {
1933
- // (*) binder moved here
1934
- let all_vars = self . tcx ( ) . mk_bound_variable_kinds (
1935
- obligation
1936
- . predicate
1937
- . bound_vars ( )
1938
- . iter ( )
1939
- . chain ( binder. bound_vars ( ) . iter ( ) ) ,
1940
- ) ;
1941
- break Where ( ty:: Binder :: bind_with_vars (
1942
- witness_tys. to_vec ( ) ,
1943
- all_vars,
1944
- ) ) ;
1945
- }
1923
+ for witness_ty in witness_tys. iter ( ) {
1924
+ let resolved = self . infcx . shallow_resolve ( witness_ty) ;
1925
+ if resolved. is_ty_var ( ) {
1926
+ return Ambiguous ;
1946
1927
}
1947
1928
}
1929
+ // (*) binder moved here
1930
+ let all_vars = self . tcx ( ) . mk_bound_variable_kinds (
1931
+ obligation. predicate . bound_vars ( ) . iter ( ) . chain ( binder. bound_vars ( ) . iter ( ) ) ,
1932
+ ) ;
1933
+ Where ( ty:: Binder :: bind_with_vars ( witness_tys. to_vec ( ) , all_vars) )
1948
1934
}
1949
1935
1950
1936
ty:: Closure ( _, substs) => {
0 commit comments