@@ -264,25 +264,21 @@ pub(crate) fn build_trait(cx: &mut DocContext<'_>, did: DefId) -> clean::Trait {
264264 . map ( |item| clean_middle_assoc_item ( item, cx) )
265265 . collect ( ) ;
266266
267- let predicates = cx. tcx . predicates_of ( did) ;
268- let generics = clean_ty_generics ( cx, cx. tcx . generics_of ( did) , predicates) ;
269- let generics = filter_non_trait_generics ( did, generics) ;
267+ let generics = clean_ty_generics ( cx, did) ;
270268 let ( generics, supertrait_bounds) = separate_self_bounds ( generics) ;
271269 clean:: Trait { def_id : did, generics, items : trait_items, bounds : supertrait_bounds }
272270}
273271
274272fn build_trait_alias ( cx : & mut DocContext < ' _ > , did : DefId ) -> clean:: TraitAlias {
275- let predicates = cx. tcx . predicates_of ( did) ;
276- let generics = clean_ty_generics ( cx, cx. tcx . generics_of ( did) , predicates) ;
273+ let generics = clean_ty_generics ( cx, did) ;
277274 let ( generics, bounds) = separate_self_bounds ( generics) ;
278275 clean:: TraitAlias { generics, bounds }
279276}
280277
281278pub ( super ) fn build_function ( cx : & mut DocContext < ' _ > , def_id : DefId ) -> Box < clean:: Function > {
282279 let sig = cx. tcx . fn_sig ( def_id) . instantiate_identity ( ) ;
283280 // The generics need to be cleaned before the signature.
284- let mut generics =
285- clean_ty_generics ( cx, cx. tcx . generics_of ( def_id) , cx. tcx . explicit_predicates_of ( def_id) ) ;
281+ let mut generics = clean_ty_generics ( cx, def_id) ;
286282 let bound_vars = clean_bound_vars ( sig. bound_vars ( ) ) ;
287283
288284 // At the time of writing early & late-bound params are stored separately in rustc,
@@ -311,30 +307,26 @@ pub(super) fn build_function(cx: &mut DocContext<'_>, def_id: DefId) -> Box<clea
311307}
312308
313309fn build_enum ( cx : & mut DocContext < ' _ > , did : DefId ) -> clean:: Enum {
314- let predicates = cx. tcx . explicit_predicates_of ( did) ;
315-
316310 clean:: Enum {
317- generics : clean_ty_generics ( cx, cx . tcx . generics_of ( did) , predicates ) ,
311+ generics : clean_ty_generics ( cx, did) ,
318312 variants : cx. tcx . adt_def ( did) . variants ( ) . iter ( ) . map ( |v| clean_variant_def ( v, cx) ) . collect ( ) ,
319313 }
320314}
321315
322316fn build_struct ( cx : & mut DocContext < ' _ > , did : DefId ) -> clean:: Struct {
323- let predicates = cx. tcx . explicit_predicates_of ( did) ;
324317 let variant = cx. tcx . adt_def ( did) . non_enum_variant ( ) ;
325318
326319 clean:: Struct {
327320 ctor_kind : variant. ctor_kind ( ) ,
328- generics : clean_ty_generics ( cx, cx . tcx . generics_of ( did) , predicates ) ,
321+ generics : clean_ty_generics ( cx, did) ,
329322 fields : variant. fields . iter ( ) . map ( |x| clean_middle_field ( x, cx) ) . collect ( ) ,
330323 }
331324}
332325
333326fn build_union ( cx : & mut DocContext < ' _ > , did : DefId ) -> clean:: Union {
334- let predicates = cx. tcx . explicit_predicates_of ( did) ;
335327 let variant = cx. tcx . adt_def ( did) . non_enum_variant ( ) ;
336328
337- let generics = clean_ty_generics ( cx, cx . tcx . generics_of ( did) , predicates ) ;
329+ let generics = clean_ty_generics ( cx, did) ;
338330 let fields = variant. fields . iter ( ) . map ( |x| clean_middle_field ( x, cx) ) . collect ( ) ;
339331 clean:: Union { generics, fields }
340332}
@@ -344,14 +336,13 @@ fn build_type_alias(
344336 did : DefId ,
345337 ret : & mut Vec < Item > ,
346338) -> Box < clean:: TypeAlias > {
347- let predicates = cx. tcx . explicit_predicates_of ( did) ;
348339 let ty = cx. tcx . type_of ( did) . instantiate_identity ( ) ;
349340 let type_ = clean_middle_ty ( ty:: Binder :: dummy ( ty) , cx, Some ( did) , None ) ;
350341 let inner_type = clean_ty_alias_inner_type ( ty, cx, ret) ;
351342
352343 Box :: new ( clean:: TypeAlias {
353344 type_,
354- generics : clean_ty_generics ( cx, cx . tcx . generics_of ( did) , predicates ) ,
345+ generics : clean_ty_generics ( cx, did) ,
355346 inner_type,
356347 item_type : None ,
357348 } )
@@ -483,7 +474,6 @@ pub(crate) fn build_impl(
483474 }
484475
485476 let document_hidden = cx. render_options . document_hidden ;
486- let predicates = tcx. explicit_predicates_of ( did) ;
487477 let ( trait_items, generics) = match impl_item {
488478 Some ( impl_) => (
489479 impl_
@@ -549,9 +539,7 @@ pub(crate) fn build_impl(
549539 } )
550540 . map ( |item| clean_middle_assoc_item ( item, cx) )
551541 . collect :: < Vec < _ > > ( ) ,
552- clean:: enter_impl_trait ( cx, |cx| {
553- clean_ty_generics ( cx, tcx. generics_of ( did) , predicates)
554- } ) ,
542+ clean:: enter_impl_trait ( cx, |cx| clean_ty_generics ( cx, did) ) ,
555543 ) ,
556544 } ;
557545 let polarity = tcx. impl_polarity ( did) ;
@@ -713,8 +701,7 @@ pub(crate) fn print_inlined_const(tcx: TyCtxt<'_>, did: DefId) -> String {
713701}
714702
715703fn build_const_item ( cx : & mut DocContext < ' _ > , def_id : DefId ) -> clean:: Constant {
716- let mut generics =
717- clean_ty_generics ( cx, cx. tcx . generics_of ( def_id) , cx. tcx . explicit_predicates_of ( def_id) ) ;
704+ let mut generics = clean_ty_generics ( cx, def_id) ;
718705 clean:: simplify:: move_bounds_to_generic_parameters ( & mut generics) ;
719706 let ty = clean_middle_ty (
720707 ty:: Binder :: dummy ( cx. tcx . type_of ( def_id) . instantiate_identity ( ) ) ,
@@ -761,44 +748,6 @@ fn build_macro(
761748 }
762749}
763750
764- /// A trait's generics clause actually contains all of the predicates for all of
765- /// its associated types as well. We specifically move these clauses to the
766- /// associated types instead when displaying, so when we're generating the
767- /// generics for the trait itself we need to be sure to remove them.
768- /// We also need to remove the implied "recursive" Self: Trait bound.
769- ///
770- /// The inverse of this filtering logic can be found in the `Clean`
771- /// implementation for `AssociatedType`
772- fn filter_non_trait_generics ( trait_did : DefId , mut g : clean:: Generics ) -> clean:: Generics {
773- for pred in & mut g. where_predicates {
774- if let clean:: WherePredicate :: BoundPredicate { ty : clean:: SelfTy , ref mut bounds, .. } =
775- * pred
776- {
777- bounds. retain ( |bound| match bound {
778- clean:: GenericBound :: TraitBound ( clean:: PolyTrait { trait_, .. } , _) => {
779- trait_. def_id ( ) != trait_did
780- }
781- _ => true ,
782- } ) ;
783- }
784- }
785-
786- g. where_predicates . retain ( |pred| match pred {
787- clean:: WherePredicate :: BoundPredicate {
788- ty :
789- clean:: QPath ( box clean:: QPathData {
790- self_type : clean:: Generic ( _) ,
791- trait_ : Some ( trait_) ,
792- ..
793- } ) ,
794- bounds,
795- ..
796- } => !bounds. is_empty ( ) && trait_. def_id ( ) != trait_did,
797- _ => true ,
798- } ) ;
799- g
800- }
801-
802751fn separate_self_bounds ( mut g : clean:: Generics ) -> ( clean:: Generics , Vec < clean:: GenericBound > ) {
803752 let mut ty_bounds = Vec :: new ( ) ;
804753 g. where_predicates . retain ( |pred| match * pred {
0 commit comments