@@ -118,6 +118,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
118118 self . assemble_future_candidates ( obligation, & mut candidates) ;
119119 } else if lang_items. iterator_trait ( ) == Some ( def_id) {
120120 self . assemble_iterator_candidates ( obligation, & mut candidates) ;
121+ } else if lang_items. fused_iterator_trait ( ) == Some ( def_id) {
122+ self . assemble_fused_iterator_candidates ( obligation, & mut candidates) ;
121123 } else if lang_items. async_iterator_trait ( ) == Some ( def_id) {
122124 self . assemble_async_iterator_candidates ( obligation, & mut candidates) ;
123125 } else if lang_items. async_fn_kind_helper ( ) == Some ( def_id) {
@@ -302,14 +304,31 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
302304 candidates : & mut SelectionCandidateSet < ' tcx > ,
303305 ) {
304306 let self_ty = obligation. self_ty ( ) . skip_binder ( ) ;
305- if let ty:: Coroutine ( did, ..) = self_ty. kind ( ) {
306- // gen constructs get lowered to a special kind of coroutine that
307- // should directly `impl Iterator`.
308- if self . tcx ( ) . coroutine_is_gen ( * did) {
309- debug ! ( ?self_ty, ?obligation, "assemble_iterator_candidates" , ) ;
307+ // gen constructs get lowered to a special kind of coroutine that
308+ // should directly `impl Iterator`.
309+ if let ty:: Coroutine ( did, ..) = self_ty. kind ( )
310+ && self . tcx ( ) . coroutine_is_gen ( * did)
311+ {
312+ debug ! ( ?self_ty, ?obligation, "assemble_iterator_candidates" , ) ;
310313
311- candidates. vec . push ( IteratorCandidate ) ;
312- }
314+ candidates. vec . push ( IteratorCandidate ) ;
315+ }
316+ }
317+
318+ fn assemble_fused_iterator_candidates (
319+ & mut self ,
320+ obligation : & PolyTraitObligation < ' tcx > ,
321+ candidates : & mut SelectionCandidateSet < ' tcx > ,
322+ ) {
323+ let self_ty = obligation. self_ty ( ) . skip_binder ( ) ;
324+ // gen constructs get lowered to a special kind of coroutine that
325+ // should directly `impl FusedIterator`.
326+ if let ty:: Coroutine ( did, ..) = self_ty. kind ( )
327+ && self . tcx ( ) . coroutine_is_gen ( * did)
328+ {
329+ debug ! ( ?self_ty, ?obligation, "assemble_fused_iterator_candidates" , ) ;
330+
331+ candidates. vec . push ( BuiltinCandidate { has_nested : false } ) ;
313332 }
314333 }
315334
0 commit comments