@@ -107,6 +107,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
107107 ImplSource :: Builtin ( BuiltinImplSource :: Misc , vtable_iterator)
108108 }
109109
110+ FusedIteratorCandidate => {
111+ let vtable_iterator = self . confirm_fused_iterator_candidate ( obligation) ?;
112+ ImplSource :: Builtin ( BuiltinImplSource :: Misc , vtable_iterator)
113+ }
114+
110115 AsyncIteratorCandidate => {
111116 let vtable_iterator = self . confirm_async_iterator_candidate ( obligation) ?;
112117 ImplSource :: Builtin ( BuiltinImplSource :: Misc , vtable_iterator)
@@ -838,6 +843,35 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
838843 Ok ( nested)
839844 }
840845
846+ fn confirm_fused_iterator_candidate (
847+ & mut self ,
848+ obligation : & PolyTraitObligation < ' tcx > ,
849+ ) -> Result < Vec < PredicateObligation < ' tcx > > , SelectionError < ' tcx > > {
850+ // Okay to skip binder because the args on coroutine types never
851+ // touch bound regions, they just capture the in-scope
852+ // type/region parameters.
853+ let self_ty = self . infcx . shallow_resolve ( obligation. self_ty ( ) . skip_binder ( ) ) ;
854+ let ty:: Coroutine ( coroutine_def_id, args) = * self_ty. kind ( ) else {
855+ bug ! ( "closure candidate for non-closure {:?}" , obligation) ;
856+ } ;
857+
858+ debug ! ( ?obligation, ?coroutine_def_id, ?args, "confirm_fused_iterator_candidate" ) ;
859+
860+ let gen_sig = args. as_coroutine ( ) . sig ( ) ;
861+
862+ let ( trait_ref, _) = super :: util:: fused_iterator_trait_ref_and_outputs (
863+ self . tcx ( ) ,
864+ obligation. predicate . def_id ( ) ,
865+ obligation. predicate . no_bound_vars ( ) . expect ( "iterator has no bound vars" ) . self_ty ( ) ,
866+ gen_sig,
867+ ) ;
868+
869+ let nested = self . confirm_poly_trait_refs ( obligation, ty:: Binder :: dummy ( trait_ref) ) ?;
870+ debug ! ( ?trait_ref, ?nested, "fused iterator candidate obligations" ) ;
871+
872+ Ok ( nested)
873+ }
874+
841875 fn confirm_async_iterator_candidate (
842876 & mut self ,
843877 obligation : & PolyTraitObligation < ' tcx > ,
0 commit comments