@@ -90,37 +90,6 @@ pub fn elaborate_trait_refs<'tcx>(
9090 elaborate_predicates ( tcx, predicates)
9191}
9292
93- /// A specialized variant of `elaborate_trait_refs` that only elaborates trait references that may
94- /// define the given associated type `assoc_name`. It uses the
95- /// `super_predicates_that_define_assoc_type` query to avoid enumerating super-predicates that
96- /// aren't related to `assoc_item`. This is used when resolving types like `Self::Item` or
97- /// `T::Item` and helps to avoid cycle errors (see e.g. #35237).
98- pub fn elaborate_trait_refs_that_define_assoc_type < ' tcx > (
99- tcx : TyCtxt < ' tcx > ,
100- trait_refs : impl Iterator < Item = ty:: PolyTraitRef < ' tcx > > ,
101- assoc_name : Ident ,
102- ) -> FxHashSet < ty:: PolyTraitRef < ' tcx > > {
103- let mut stack: Vec < _ > = trait_refs. collect ( ) ;
104- let mut trait_refs = FxHashSet :: default ( ) ;
105-
106- while let Some ( trait_ref) = stack. pop ( ) {
107- if trait_refs. insert ( trait_ref) {
108- let super_predicates =
109- tcx. super_predicates_that_define_assoc_type ( ( trait_ref. def_id ( ) , Some ( assoc_name) ) ) ;
110- for ( super_predicate, _) in super_predicates. predicates {
111- let bound_predicate = super_predicate. bound_atom ( ) ;
112- let subst_predicate = super_predicate
113- . subst_supertrait ( tcx, & bound_predicate. rebind ( trait_ref. skip_binder ( ) ) ) ;
114- if let Some ( binder) = subst_predicate. to_opt_poly_trait_ref ( ) {
115- stack. push ( binder. value ) ;
116- }
117- }
118- }
119- }
120-
121- trait_refs
122- }
123-
12493pub fn elaborate_predicates < ' tcx > (
12594 tcx : TyCtxt < ' tcx > ,
12695 predicates : impl Iterator < Item = ty:: Predicate < ' tcx > > ,
@@ -319,12 +288,35 @@ pub fn transitive_bounds<'tcx>(
319288 elaborate_trait_refs ( tcx, bounds) . filter_to_traits ( )
320289}
321290
291+ /// A specialized variant of `elaborate_trait_refs` that only elaborates trait references that may
292+ /// define the given associated type `assoc_name`. It uses the
293+ /// `super_predicates_that_define_assoc_type` query to avoid enumerating super-predicates that
294+ /// aren't related to `assoc_item`. This is used when resolving types like `Self::Item` or
295+ /// `T::Item` and helps to avoid cycle errors (see e.g. #35237).
322296pub fn transitive_bounds_that_define_assoc_type < ' tcx > (
323297 tcx : TyCtxt < ' tcx > ,
324298 bounds : impl Iterator < Item = ty:: PolyTraitRef < ' tcx > > ,
325299 assoc_name : Ident ,
326300) -> FxHashSet < ty:: PolyTraitRef < ' tcx > > {
327- elaborate_trait_refs_that_define_assoc_type ( tcx, bounds, assoc_name)
301+ let mut stack: Vec < _ > = bounds. collect ( ) ;
302+ let mut trait_refs = FxHashSet :: default ( ) ;
303+
304+ while let Some ( trait_ref) = stack. pop ( ) {
305+ if trait_refs. insert ( trait_ref) {
306+ let super_predicates =
307+ tcx. super_predicates_that_define_assoc_type ( ( trait_ref. def_id ( ) , Some ( assoc_name) ) ) ;
308+ for ( super_predicate, _) in super_predicates. predicates {
309+ let bound_predicate = super_predicate. bound_atom ( ) ;
310+ let subst_predicate = super_predicate
311+ . subst_supertrait ( tcx, & bound_predicate. rebind ( trait_ref. skip_binder ( ) ) ) ;
312+ if let Some ( binder) = subst_predicate. to_opt_poly_trait_ref ( ) {
313+ stack. push ( binder. value ) ;
314+ }
315+ }
316+ }
317+ }
318+
319+ trait_refs
328320}
329321
330322///////////////////////////////////////////////////////////////////////////
0 commit comments