@@ -156,7 +156,7 @@ impl<'tcx> Clean<'tcx, Option<GenericBound>> for hir::GenericBound<'tcx> {
156
156
return None ;
157
157
}
158
158
159
- GenericBound :: TraitBound ( t . clean ( cx) , modifier)
159
+ GenericBound :: TraitBound ( clean_poly_trait_ref ( t , cx) , modifier)
160
160
}
161
161
} )
162
162
}
@@ -1001,69 +1001,68 @@ fn clean_trait_ref<'tcx>(trait_ref: &hir::TraitRef<'tcx>, cx: &mut DocContext<'t
1001
1001
path
1002
1002
}
1003
1003
1004
- impl < ' tcx > Clean < ' tcx , PolyTrait > for hir:: PolyTraitRef < ' tcx > {
1005
- fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> PolyTrait {
1006
- PolyTrait {
1007
- trait_ : clean_trait_ref ( & self . trait_ref , cx) ,
1008
- generic_params : self
1009
- . bound_generic_params
1010
- . iter ( )
1011
- . filter ( |p| !is_elided_lifetime ( p) )
1012
- . map ( |x| clean_generic_param ( cx, None , x) )
1013
- . collect ( ) ,
1014
- }
1004
+ fn clean_poly_trait_ref < ' tcx > (
1005
+ poly_trait_ref : & hir:: PolyTraitRef < ' tcx > ,
1006
+ cx : & mut DocContext < ' tcx > ,
1007
+ ) -> PolyTrait {
1008
+ PolyTrait {
1009
+ trait_ : clean_trait_ref ( & poly_trait_ref. trait_ref , cx) ,
1010
+ generic_params : poly_trait_ref
1011
+ . bound_generic_params
1012
+ . iter ( )
1013
+ . filter ( |p| !is_elided_lifetime ( p) )
1014
+ . map ( |x| clean_generic_param ( cx, None , x) )
1015
+ . collect ( ) ,
1015
1016
}
1016
1017
}
1017
1018
1018
- impl < ' tcx > Clean < ' tcx , Item > for hir:: TraitItem < ' tcx > {
1019
- fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> Item {
1020
- let local_did = self . def_id . to_def_id ( ) ;
1021
- cx. with_param_env ( local_did, |cx| {
1022
- let inner = match self . kind {
1023
- hir:: TraitItemKind :: Const ( ty, Some ( default) ) => AssocConstItem (
1024
- clean_ty ( ty, cx) ,
1025
- ConstantKind :: Local { def_id : local_did, body : default } ,
1026
- ) ,
1027
- hir:: TraitItemKind :: Const ( ty, None ) => TyAssocConstItem ( clean_ty ( ty, cx) ) ,
1028
- hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Provided ( body) ) => {
1029
- let m = clean_function ( cx, sig, self . generics , body) ;
1030
- MethodItem ( m, None )
1031
- }
1032
- hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Required ( names) ) => {
1033
- let ( generics, decl) = enter_impl_trait ( cx, |cx| {
1034
- // NOTE: generics must be cleaned before args
1035
- let generics = self . generics . clean ( cx) ;
1036
- let args = clean_args_from_types_and_names ( cx, sig. decl . inputs , names) ;
1037
- let decl = clean_fn_decl_with_args ( cx, sig. decl , args) ;
1038
- ( generics, decl)
1039
- } ) ;
1040
- TyMethodItem ( Box :: new ( Function { decl, generics } ) )
1041
- }
1042
- hir:: TraitItemKind :: Type ( bounds, Some ( default) ) => {
1043
- let generics = enter_impl_trait ( cx, |cx| self . generics . clean ( cx) ) ;
1044
- let bounds = bounds. iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ;
1045
- let item_type = clean_middle_ty ( hir_ty_to_ty ( cx. tcx , default) , cx, None ) ;
1046
- AssocTypeItem (
1047
- Box :: new ( Typedef {
1048
- type_ : clean_ty ( default, cx) ,
1049
- generics,
1050
- item_type : Some ( item_type) ,
1051
- } ) ,
1052
- bounds,
1053
- )
1054
- }
1055
- hir:: TraitItemKind :: Type ( bounds, None ) => {
1056
- let generics = enter_impl_trait ( cx, |cx| self . generics . clean ( cx) ) ;
1057
- let bounds = bounds. iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ;
1058
- TyAssocTypeItem ( Box :: new ( generics) , bounds)
1059
- }
1060
- } ;
1061
- let what_rustc_thinks =
1062
- Item :: from_def_id_and_parts ( local_did, Some ( self . ident . name ) , inner, cx) ;
1063
- // Trait items always inherit the trait's visibility -- we don't want to show `pub`.
1064
- Item { visibility : Inherited , ..what_rustc_thinks }
1065
- } )
1066
- }
1019
+ fn clean_trait_item < ' tcx > ( trait_item : & hir:: TraitItem < ' tcx > , cx : & mut DocContext < ' tcx > ) -> Item {
1020
+ let local_did = trait_item. def_id . to_def_id ( ) ;
1021
+ cx. with_param_env ( local_did, |cx| {
1022
+ let inner = match trait_item. kind {
1023
+ hir:: TraitItemKind :: Const ( ty, Some ( default) ) => AssocConstItem (
1024
+ clean_ty ( ty, cx) ,
1025
+ ConstantKind :: Local { def_id : local_did, body : default } ,
1026
+ ) ,
1027
+ hir:: TraitItemKind :: Const ( ty, None ) => TyAssocConstItem ( clean_ty ( ty, cx) ) ,
1028
+ hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Provided ( body) ) => {
1029
+ let m = clean_function ( cx, sig, trait_item. generics , body) ;
1030
+ MethodItem ( m, None )
1031
+ }
1032
+ hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Required ( names) ) => {
1033
+ let ( generics, decl) = enter_impl_trait ( cx, |cx| {
1034
+ // NOTE: generics must be cleaned before args
1035
+ let generics = trait_item. generics . clean ( cx) ;
1036
+ let args = clean_args_from_types_and_names ( cx, sig. decl . inputs , names) ;
1037
+ let decl = clean_fn_decl_with_args ( cx, sig. decl , args) ;
1038
+ ( generics, decl)
1039
+ } ) ;
1040
+ TyMethodItem ( Box :: new ( Function { decl, generics } ) )
1041
+ }
1042
+ hir:: TraitItemKind :: Type ( bounds, Some ( default) ) => {
1043
+ let generics = enter_impl_trait ( cx, |cx| trait_item. generics . clean ( cx) ) ;
1044
+ let bounds = bounds. iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ;
1045
+ let item_type = clean_middle_ty ( hir_ty_to_ty ( cx. tcx , default) , cx, None ) ;
1046
+ AssocTypeItem (
1047
+ Box :: new ( Typedef {
1048
+ type_ : clean_ty ( default, cx) ,
1049
+ generics,
1050
+ item_type : Some ( item_type) ,
1051
+ } ) ,
1052
+ bounds,
1053
+ )
1054
+ }
1055
+ hir:: TraitItemKind :: Type ( bounds, None ) => {
1056
+ let generics = enter_impl_trait ( cx, |cx| trait_item. generics . clean ( cx) ) ;
1057
+ let bounds = bounds. iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ;
1058
+ TyAssocTypeItem ( Box :: new ( generics) , bounds)
1059
+ }
1060
+ } ;
1061
+ let what_rustc_thinks =
1062
+ Item :: from_def_id_and_parts ( local_did, Some ( trait_item. ident . name ) , inner, cx) ;
1063
+ // Trait items always inherit the trait's visibility -- we don't want to show `pub`.
1064
+ Item { visibility : Inherited , ..what_rustc_thinks }
1065
+ } )
1067
1066
}
1068
1067
1069
1068
impl < ' tcx > Clean < ' tcx , Item > for hir:: ImplItem < ' tcx > {
@@ -1515,7 +1514,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
1515
1514
}
1516
1515
TyKind :: Path ( _) => clean_qpath ( ty, cx) ,
1517
1516
TyKind :: TraitObject ( bounds, ref lifetime, _) => {
1518
- let bounds = bounds. iter ( ) . map ( |bound| bound . clean ( cx) ) . collect ( ) ;
1517
+ let bounds = bounds. iter ( ) . map ( |bound| clean_poly_trait_ref ( bound , cx) ) . collect ( ) ;
1519
1518
let lifetime =
1520
1519
if !lifetime. is_elided ( ) { Some ( clean_lifetime ( * lifetime, cx) ) } else { None } ;
1521
1520
DynTrait ( bounds, lifetime)
@@ -1953,8 +1952,10 @@ fn clean_maybe_renamed_item<'tcx>(
1953
1952
} )
1954
1953
}
1955
1954
ItemKind :: Trait ( _, _, generics, bounds, item_ids) => {
1956
- let items =
1957
- item_ids. iter ( ) . map ( |ti| cx. tcx . hir ( ) . trait_item ( ti. id ) . clean ( cx) ) . collect ( ) ;
1955
+ let items = item_ids
1956
+ . iter ( )
1957
+ . map ( |ti| clean_trait_item ( cx. tcx . hir ( ) . trait_item ( ti. id ) , cx) )
1958
+ . collect ( ) ;
1958
1959
1959
1960
TraitItem ( Trait {
1960
1961
def_id,
0 commit comments