@@ -74,44 +74,58 @@ pub struct Elaborator<'tcx> {
7474pub  fn  elaborate_trait_ref < ' tcx > ( 
7575    tcx :  TyCtxt < ' tcx > , 
7676    trait_ref :  ty:: PolyTraitRef < ' tcx > , 
77- )  -> Elaborator < ' tcx >  { 
77+ )  -> impl   Iterator < Item  = ty :: Predicate < ' tcx > >  { 
7878    elaborate_predicates ( tcx,  std:: iter:: once ( trait_ref. without_const ( ) . to_predicate ( tcx) ) ) 
7979} 
8080
8181pub  fn  elaborate_trait_refs < ' tcx > ( 
8282    tcx :  TyCtxt < ' tcx > , 
8383    trait_refs :  impl  Iterator < Item  = ty:: PolyTraitRef < ' tcx > > , 
84- )  -> Elaborator < ' tcx >  { 
85-     let  predicates = trait_refs. map ( |trait_ref| trait_ref. without_const ( ) . to_predicate ( tcx) ) ; 
84+ )  -> impl   Iterator < Item  = ty :: Predicate < ' tcx > >  { 
85+     let  predicates = trait_refs. map ( move   |trait_ref| trait_ref. without_const ( ) . to_predicate ( tcx) ) ; 
8686    elaborate_predicates ( tcx,  predicates) 
8787} 
8888
8989pub  fn  elaborate_predicates < ' tcx > ( 
9090    tcx :  TyCtxt < ' tcx > , 
9191    predicates :  impl  Iterator < Item  = ty:: Predicate < ' tcx > > , 
92- )  -> Elaborator < ' tcx >  { 
93-     let  obligations = predicates
94-         . map ( |predicate| { 
95-             predicate_obligation ( predicate,  ty:: ParamEnv :: empty ( ) ,  ObligationCause :: dummy ( ) ) 
96-         } ) 
97-         . collect ( ) ; 
98-     elaborate_obligations ( tcx,  obligations) 
92+ )  -> impl  Iterator < Item  = ty:: Predicate < ' tcx > >  { 
93+     elaborate_obligations ( 
94+         tcx, 
95+         predicates
96+             . map ( |predicate| { 
97+                 Obligation :: new ( 
98+                     tcx, 
99+                     // We'll dump the cause/param-env later 
100+                     ObligationCause :: dummy ( ) , 
101+                     ty:: ParamEnv :: empty ( ) , 
102+                     predicate, 
103+                 ) 
104+             } ) 
105+             . collect ( ) , 
106+     ) 
107+     . map ( |obl| obl. predicate ) 
99108} 
100109
101110pub  fn  elaborate_predicates_with_span < ' tcx > ( 
102111    tcx :  TyCtxt < ' tcx > , 
103112    predicates :  impl  Iterator < Item  = ( ty:: Predicate < ' tcx > ,  Span ) > , 
104- )  -> Elaborator < ' tcx >  { 
105-     let  obligations = predicates
106-         . map ( |( predicate,  span) | { 
107-             predicate_obligation ( 
108-                 predicate, 
109-                 ty:: ParamEnv :: empty ( ) , 
110-                 ObligationCause :: dummy_with_span ( span) , 
111-             ) 
112-         } ) 
113-         . collect ( ) ; 
114-     elaborate_obligations ( tcx,  obligations) 
113+ )  -> impl  Iterator < Item  = ( ty:: Predicate < ' tcx > ,  Span ) >  { 
114+     elaborate_obligations ( 
115+         tcx, 
116+         predicates
117+             . map ( |( predicate,  span) | { 
118+                 Obligation :: new ( 
119+                     tcx, 
120+                     // We'll dump the cause/param-env later 
121+                     ObligationCause :: dummy_with_span ( span) , 
122+                     ty:: ParamEnv :: empty ( ) , 
123+                     predicate, 
124+                 ) 
125+             } ) 
126+             . collect ( ) , 
127+     ) 
128+     . map ( |obl| ( obl. predicate ,  obl. cause . span ) ) 
115129} 
116130
117131pub  fn  elaborate_obligations < ' tcx > ( 
@@ -141,10 +155,6 @@ impl<'tcx> Elaborator<'tcx> {
141155        self . stack . extend ( obligations. into_iter ( ) . filter ( |o| self . visited . insert ( o. predicate ) ) ) ; 
142156    } 
143157
144-     pub  fn  filter_to_traits ( self )  -> FilterToTraits < Self >  { 
145-         FilterToTraits :: new ( self ) 
146-     } 
147- 
148158    fn  elaborate ( & mut  self ,  obligation :  & PredicateObligation < ' tcx > )  { 
149159        let  tcx = self . visited . tcx ; 
150160
@@ -325,20 +335,18 @@ impl<'tcx> Iterator for Elaborator<'tcx> {
325335// Supertrait iterator 
326336/////////////////////////////////////////////////////////////////////////// 
327337
328- pub  type  Supertraits < ' tcx >  = FilterToTraits < Elaborator < ' tcx > > ; 
329- 
330338pub  fn  supertraits < ' tcx > ( 
331339    tcx :  TyCtxt < ' tcx > , 
332340    trait_ref :  ty:: PolyTraitRef < ' tcx > , 
333- )  -> Supertraits < ' tcx >  { 
334-     elaborate_trait_ref ( tcx,  trait_ref) . filter_to_traits ( ) 
341+ )  -> impl   Iterator < Item  = ty :: PolyTraitRef < ' tcx > >  { 
342+     FilterToTraits :: new ( elaborate_trait_ref ( tcx,  trait_ref) ) 
335343} 
336344
337345pub  fn  transitive_bounds < ' tcx > ( 
338346    tcx :  TyCtxt < ' tcx > , 
339-     bounds :  impl  Iterator < Item  = ty:: PolyTraitRef < ' tcx > > , 
340- )  -> Supertraits < ' tcx >  { 
341-     elaborate_trait_refs ( tcx,  bounds ) . filter_to_traits ( ) 
347+     trait_refs :  impl  Iterator < Item  = ty:: PolyTraitRef < ' tcx > > , 
348+ )  -> impl   Iterator < Item  = ty :: PolyTraitRef < ' tcx > >  { 
349+     FilterToTraits :: new ( elaborate_trait_refs ( tcx,  trait_refs ) ) 
342350} 
343351
344352/// A specialized variant of `elaborate_trait_refs` that only elaborates trait references that may 
@@ -393,12 +401,12 @@ impl<I> FilterToTraits<I> {
393401    } 
394402} 
395403
396- impl < ' tcx ,  I :  Iterator < Item  = PredicateObligation < ' tcx > > >  Iterator  for  FilterToTraits < I >  { 
404+ impl < ' tcx ,  I :  Iterator < Item  = ty :: Predicate < ' tcx > > >  Iterator  for  FilterToTraits < I >  { 
397405    type  Item  = ty:: PolyTraitRef < ' tcx > ; 
398406
399407    fn  next ( & mut  self )  -> Option < ty:: PolyTraitRef < ' tcx > >  { 
400-         while  let  Some ( obligation )  = self . base_iterator . next ( )  { 
401-             if  let  Some ( data)  = obligation . predicate . to_opt_poly_trait_pred ( )  { 
408+         while  let  Some ( pred )  = self . base_iterator . next ( )  { 
409+             if  let  Some ( data)  = pred . to_opt_poly_trait_pred ( )  { 
402410                return  Some ( data. map_bound ( |t| t. trait_ref ) ) ; 
403411            } 
404412        } 
0 commit comments