@@ -232,20 +232,11 @@ fn clean_poly_trait_ref_with_bindings<'tcx>(
232232 poly_trait_ref : ty:: PolyTraitRef < ' tcx > ,
233233 bindings : ThinVec < TypeBinding > ,
234234) -> GenericBound {
235- // collect any late bound regions
236- let late_bound_regions: Vec < _ > = cx
237- . tcx
238- . collect_referenced_late_bound_regions ( & poly_trait_ref)
239- . into_iter ( )
240- . filter_map ( |br| match br {
241- ty:: BrNamed ( _, name) if br. is_named ( ) => Some ( GenericParamDef :: lifetime ( name) ) ,
242- _ => None ,
243- } )
244- . collect ( ) ;
245-
246- let trait_ = clean_trait_ref_with_bindings ( cx, poly_trait_ref, bindings) ;
247235 GenericBound :: TraitBound (
248- PolyTrait { trait_, generic_params : late_bound_regions } ,
236+ PolyTrait {
237+ trait_ : clean_trait_ref_with_bindings ( cx, poly_trait_ref, bindings) ,
238+ generic_params : clean_bound_vars ( poly_trait_ref. bound_vars ( ) ) ,
239+ } ,
249240 hir:: TraitBoundModifier :: None ,
250241 )
251242}
@@ -338,9 +329,8 @@ fn clean_where_predicate<'tcx>(
338329 } ,
339330
340331 hir:: WherePredicate :: EqPredicate ( ref wrp) => WherePredicate :: EqPredicate {
341- lhs : Box :: new ( clean_ty ( wrp. lhs_ty , cx) ) ,
342- rhs : Box :: new ( clean_ty ( wrp. rhs_ty , cx) . into ( ) ) ,
343- bound_params : Vec :: new ( ) ,
332+ lhs : clean_ty ( wrp. lhs_ty , cx) ,
333+ rhs : clean_ty ( wrp. rhs_ty , cx) . into ( ) ,
344334 } ,
345335 } )
346336}
@@ -436,20 +426,9 @@ fn clean_projection_predicate<'tcx>(
436426 pred : ty:: Binder < ' tcx , ty:: ProjectionPredicate < ' tcx > > ,
437427 cx : & mut DocContext < ' tcx > ,
438428) -> WherePredicate {
439- let late_bound_regions = cx
440- . tcx
441- . collect_referenced_late_bound_regions ( & pred)
442- . into_iter ( )
443- . filter_map ( |br| match br {
444- ty:: BrNamed ( _, name) if br. is_named ( ) => Some ( GenericParamDef :: lifetime ( name) ) ,
445- _ => None ,
446- } )
447- . collect ( ) ;
448-
449429 WherePredicate :: EqPredicate {
450- lhs : Box :: new ( clean_projection ( pred. map_bound ( |p| p. projection_ty ) , cx, None ) ) ,
451- rhs : Box :: new ( clean_middle_term ( pred. map_bound ( |p| p. term ) , cx) ) ,
452- bound_params : late_bound_regions,
430+ lhs : clean_projection ( pred. map_bound ( |p| p. projection_ty ) , cx, None ) ,
431+ rhs : clean_middle_term ( pred. map_bound ( |p| p. term ) , cx) ,
453432 }
454433}
455434
@@ -703,8 +682,8 @@ pub(crate) fn clean_generics<'tcx>(
703682 }
704683 }
705684 }
706- WherePredicate :: EqPredicate { lhs, rhs, bound_params } => {
707- eq_predicates. push ( WherePredicate :: EqPredicate { lhs, rhs, bound_params } ) ;
685+ WherePredicate :: EqPredicate { lhs, rhs } => {
686+ eq_predicates. push ( WherePredicate :: EqPredicate { lhs, rhs } ) ;
708687 }
709688 }
710689 }
@@ -798,11 +777,9 @@ fn clean_ty_generics<'tcx>(
798777 } )
799778 . collect :: < ThinVec < GenericParamDef > > ( ) ;
800779
801- // param index -> [(trait DefId, associated type name & generics, term, higher-ranked params)]
802- let mut impl_trait_proj = FxHashMap :: <
803- u32 ,
804- Vec < ( DefId , PathSegment , ty:: Binder < ' _ , ty:: Term < ' _ > > , Vec < GenericParamDef > ) > ,
805- > :: default ( ) ;
780+ // param index -> [(trait DefId, associated type name & generics, term)]
781+ let mut impl_trait_proj =
782+ FxHashMap :: < u32 , Vec < ( DefId , PathSegment , ty:: Binder < ' _ , ty:: Term < ' _ > > ) > > :: default ( ) ;
806783
807784 let where_predicates = preds
808785 . predicates
@@ -854,11 +831,6 @@ fn clean_ty_generics<'tcx>(
854831 trait_did,
855832 name,
856833 proj. map_bound ( |p| p. term ) ,
857- pred. get_bound_params ( )
858- . into_iter ( )
859- . flatten ( )
860- . cloned ( )
861- . collect ( ) ,
862834 ) ) ;
863835 }
864836
@@ -894,9 +866,9 @@ fn clean_ty_generics<'tcx>(
894866
895867 let crate :: core:: ImplTraitParam :: ParamIndex ( idx) = param else { unreachable ! ( ) } ;
896868 if let Some ( proj) = impl_trait_proj. remove ( & idx) {
897- for ( trait_did, name, rhs, bound_params ) in proj {
869+ for ( trait_did, name, rhs) in proj {
898870 let rhs = clean_middle_term ( rhs, cx) ;
899- simplify:: merge_bounds ( cx, & mut bounds, bound_params , trait_did, name, & rhs) ;
871+ simplify:: merge_bounds ( cx, & mut bounds, trait_did, name, & rhs) ;
900872 }
901873 }
902874
@@ -1357,23 +1329,13 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
13571329 }
13581330 ty:: AssocKind :: Fn => {
13591331 let sig = tcx. fn_sig ( assoc_item. def_id ) . instantiate_identity ( ) ;
1360-
1361- let late_bound_regions = sig. bound_vars ( ) . into_iter ( ) . filter_map ( |var| match var {
1362- ty:: BoundVariableKind :: Region ( ty:: BrNamed ( _, name) )
1363- if name != kw:: UnderscoreLifetime =>
1364- {
1365- Some ( GenericParamDef :: lifetime ( name) )
1366- }
1367- _ => None ,
1368- } ) ;
1369-
13701332 let mut generics = clean_ty_generics (
13711333 cx,
13721334 tcx. generics_of ( assoc_item. def_id ) ,
13731335 tcx. explicit_predicates_of ( assoc_item. def_id ) ,
13741336 ) ;
13751337 // FIXME: This does not place parameters in source order (late-bound ones come last)
1376- generics. params . extend ( late_bound_regions ) ;
1338+ generics. params . extend ( clean_bound_vars ( sig . bound_vars ( ) ) ) ;
13771339
13781340 let mut decl = clean_fn_decl_from_did_and_sig ( cx, Some ( assoc_item. def_id ) , sig) ;
13791341
@@ -2109,9 +2071,11 @@ pub(crate) fn clean_middle_ty<'tcx>(
21092071 // FIXME: should we merge the outer and inner binders somehow?
21102072 let sig = bound_ty. skip_binder ( ) . fn_sig ( cx. tcx ) ;
21112073 let decl = clean_fn_decl_from_did_and_sig ( cx, None , sig) ;
2074+ let generic_params = clean_bound_vars ( sig. bound_vars ( ) ) ;
2075+
21122076 BareFunction ( Box :: new ( BareFunctionDecl {
21132077 unsafety : sig. unsafety ( ) ,
2114- generic_params : Vec :: new ( ) ,
2078+ generic_params,
21152079 decl,
21162080 abi : sig. abi ( ) ,
21172081 } ) )
@@ -2187,8 +2151,8 @@ pub(crate) fn clean_middle_ty<'tcx>(
21872151
21882152 let late_bound_regions: FxIndexSet < _ > = obj
21892153 . iter ( )
2190- . flat_map ( |pb| pb . bound_vars ( ) )
2191- . filter_map ( |br | match br {
2154+ . flat_map ( |pred| pred . bound_vars ( ) )
2155+ . filter_map ( |var | match var {
21922156 ty:: BoundVariableKind :: Region ( ty:: BrNamed ( _, name) )
21932157 if name != kw:: UnderscoreLifetime =>
21942158 {
@@ -3121,3 +3085,19 @@ fn clean_type_binding<'tcx>(
31213085 } ,
31223086 }
31233087}
3088+
3089+ fn clean_bound_vars < ' tcx > (
3090+ bound_vars : & ' tcx ty:: List < ty:: BoundVariableKind > ,
3091+ ) -> Vec < GenericParamDef > {
3092+ bound_vars
3093+ . into_iter ( )
3094+ . filter_map ( |var| match var {
3095+ ty:: BoundVariableKind :: Region ( ty:: BrNamed ( _, name) )
3096+ if name != kw:: UnderscoreLifetime =>
3097+ {
3098+ Some ( GenericParamDef :: lifetime ( name) )
3099+ }
3100+ _ => None ,
3101+ } )
3102+ . collect ( )
3103+ }
0 commit comments