@@ -232,20 +232,11 @@ fn clean_poly_trait_ref_with_bindings<'tcx>(
232
232
poly_trait_ref : ty:: PolyTraitRef < ' tcx > ,
233
233
bindings : ThinVec < TypeBinding > ,
234
234
) -> 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) ;
247
235
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
+ } ,
249
240
hir:: TraitBoundModifier :: None ,
250
241
)
251
242
}
@@ -338,9 +329,8 @@ fn clean_where_predicate<'tcx>(
338
329
} ,
339
330
340
331
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 ( ) ,
344
334
} ,
345
335
} )
346
336
}
@@ -436,20 +426,9 @@ fn clean_projection_predicate<'tcx>(
436
426
pred : ty:: Binder < ' tcx , ty:: ProjectionPredicate < ' tcx > > ,
437
427
cx : & mut DocContext < ' tcx > ,
438
428
) -> 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
-
449
429
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) ,
453
432
}
454
433
}
455
434
@@ -703,8 +682,8 @@ pub(crate) fn clean_generics<'tcx>(
703
682
}
704
683
}
705
684
}
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 } ) ;
708
687
}
709
688
}
710
689
}
@@ -798,11 +777,9 @@ fn clean_ty_generics<'tcx>(
798
777
} )
799
778
. collect :: < ThinVec < GenericParamDef > > ( ) ;
800
779
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 ( ) ;
806
783
807
784
let where_predicates = preds
808
785
. predicates
@@ -854,11 +831,6 @@ fn clean_ty_generics<'tcx>(
854
831
trait_did,
855
832
name,
856
833
proj. map_bound ( |p| p. term ) ,
857
- pred. get_bound_params ( )
858
- . into_iter ( )
859
- . flatten ( )
860
- . cloned ( )
861
- . collect ( ) ,
862
834
) ) ;
863
835
}
864
836
@@ -894,9 +866,9 @@ fn clean_ty_generics<'tcx>(
894
866
895
867
let crate :: core:: ImplTraitParam :: ParamIndex ( idx) = param else { unreachable ! ( ) } ;
896
868
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 {
898
870
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) ;
900
872
}
901
873
}
902
874
@@ -1357,23 +1329,13 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
1357
1329
}
1358
1330
ty:: AssocKind :: Fn => {
1359
1331
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
-
1370
1332
let mut generics = clean_ty_generics (
1371
1333
cx,
1372
1334
tcx. generics_of ( assoc_item. def_id ) ,
1373
1335
tcx. explicit_predicates_of ( assoc_item. def_id ) ,
1374
1336
) ;
1375
1337
// 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 ( ) ) ) ;
1377
1339
1378
1340
let mut decl = clean_fn_decl_from_did_and_sig ( cx, Some ( assoc_item. def_id ) , sig) ;
1379
1341
@@ -2109,9 +2071,11 @@ pub(crate) fn clean_middle_ty<'tcx>(
2109
2071
// FIXME: should we merge the outer and inner binders somehow?
2110
2072
let sig = bound_ty. skip_binder ( ) . fn_sig ( cx. tcx ) ;
2111
2073
let decl = clean_fn_decl_from_did_and_sig ( cx, None , sig) ;
2074
+ let generic_params = clean_bound_vars ( sig. bound_vars ( ) ) ;
2075
+
2112
2076
BareFunction ( Box :: new ( BareFunctionDecl {
2113
2077
unsafety : sig. unsafety ( ) ,
2114
- generic_params : Vec :: new ( ) ,
2078
+ generic_params,
2115
2079
decl,
2116
2080
abi : sig. abi ( ) ,
2117
2081
} ) )
@@ -2187,8 +2151,8 @@ pub(crate) fn clean_middle_ty<'tcx>(
2187
2151
2188
2152
let late_bound_regions: FxIndexSet < _ > = obj
2189
2153
. 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 {
2192
2156
ty:: BoundVariableKind :: Region ( ty:: BrNamed ( _, name) )
2193
2157
if name != kw:: UnderscoreLifetime =>
2194
2158
{
@@ -3121,3 +3085,19 @@ fn clean_type_binding<'tcx>(
3121
3085
} ,
3122
3086
}
3123
3087
}
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