@@ -55,12 +55,6 @@ crate trait Clean<T> {
5555 fn clean ( & self , cx : & mut DocContext < ' _ > ) -> T ;
5656}
5757
58- impl < T : Clean < U > , U > Clean < Vec < U > > for [ T ] {
59- fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Vec < U > {
60- self . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( )
61- }
62- }
63-
6458impl < T : Clean < U > , U > Clean < U > for & T {
6559 fn clean ( & self , cx : & mut DocContext < ' _ > ) -> U {
6660 ( * * self ) . clean ( cx)
@@ -274,14 +268,14 @@ impl Clean<WherePredicate> for hir::WherePredicate<'_> {
274268 . collect ( ) ;
275269 WherePredicate :: BoundPredicate {
276270 ty : wbp. bounded_ty . clean ( cx) ,
277- bounds : wbp. bounds . clean ( cx) ,
271+ bounds : wbp. bounds . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
278272 bound_params,
279273 }
280274 }
281275
282276 hir:: WherePredicate :: RegionPredicate ( ref wrp) => WherePredicate :: RegionPredicate {
283277 lifetime : wrp. lifetime . clean ( cx) ,
284- bounds : wrp. bounds . clean ( cx) ,
278+ bounds : wrp. bounds . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
285279 } ,
286280
287281 hir:: WherePredicate :: EqPredicate ( ref wrp) => {
@@ -446,7 +440,7 @@ impl Clean<GenericParamDef> for hir::GenericParam<'_> {
446440 self . name . ident ( ) . name ,
447441 GenericParamDefKind :: Type {
448442 did : cx. tcx . hir ( ) . local_def_id ( self . hir_id ) . to_def_id ( ) ,
449- bounds : self . bounds . clean ( cx) ,
443+ bounds : self . bounds . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
450444 default : default. map ( |t| t. clean ( cx) ) . map ( Box :: new) ,
451445 synthetic,
452446 } ,
@@ -517,8 +511,10 @@ impl Clean<Generics> for hir::Generics<'_> {
517511 }
518512 params. extend ( impl_trait_params) ;
519513
520- let mut generics =
521- Generics { params, where_predicates : self . where_clause . predicates . clean ( cx) } ;
514+ let mut generics = Generics {
515+ params,
516+ where_predicates : self . where_clause . predicates . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
517+ } ;
522518
523519 // Some duplicates are generated for ?Sized bounds between type params and where
524520 // predicates. The point in here is to move the bounds definitions from type params
@@ -887,7 +883,7 @@ impl Clean<PolyTrait> for hir::PolyTraitRef<'_> {
887883 fn clean ( & self , cx : & mut DocContext < ' _ > ) -> PolyTrait {
888884 PolyTrait {
889885 trait_ : self . trait_ref . clean ( cx) ,
890- generic_params : self . bound_generic_params . clean ( cx) ,
886+ generic_params : self . bound_generic_params . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
891887 }
892888 }
893889}
@@ -922,7 +918,9 @@ impl Clean<Item> for hir::TraitItem<'_> {
922918 TyMethodItem ( t)
923919 }
924920 hir:: TraitItemKind :: Type ( bounds, ref default) => {
925- AssocTypeItem ( bounds. clean ( cx) , default. map ( |t| t. clean ( cx) ) )
921+ let bounds = bounds. iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ;
922+ let default = default. map ( |t| t. clean ( cx) ) ;
923+ AssocTypeItem ( bounds, default)
926924 }
927925 } ;
928926 let what_rustc_thinks =
@@ -1256,7 +1254,7 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
12561254 let trait_def = cx. tcx . associated_item ( p. res . def_id ( ) ) . container . id ( ) ;
12571255 let trait_ = self :: Path {
12581256 res : Res :: Def ( DefKind :: Trait , trait_def) ,
1259- segments : trait_segments. clean ( cx) ,
1257+ segments : trait_segments. iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
12601258 } ;
12611259 register_res ( cx, trait_. res ) ;
12621260 Type :: QPath {
@@ -1322,11 +1320,11 @@ impl Clean<Type> for hir::Ty<'_> {
13221320 let length = print_const ( cx, ct. eval ( cx. tcx , param_env) ) ;
13231321 Array ( box ty. clean ( cx) , length)
13241322 }
1325- TyKind :: Tup ( tys) => Tuple ( tys. clean ( cx) ) ,
1323+ TyKind :: Tup ( tys) => Tuple ( tys. iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ) ,
13261324 TyKind :: OpaqueDef ( item_id, _) => {
13271325 let item = cx. tcx . hir ( ) . item ( item_id) ;
13281326 if let hir:: ItemKind :: OpaqueTy ( ref ty) = item. kind {
1329- ImplTrait ( ty. bounds . clean ( cx) )
1327+ ImplTrait ( ty. bounds . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) )
13301328 } else {
13311329 unreachable ! ( )
13321330 }
@@ -1466,7 +1464,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
14661464
14671465 DynTrait ( bounds, lifetime)
14681466 }
1469- ty:: Tuple ( t) => Tuple ( t. iter ( ) . map ( |t| t. expect_ty ( ) ) . collect :: < Vec < _ > > ( ) . clean ( cx ) ) ,
1467+ ty:: Tuple ( t) => Tuple ( t. iter ( ) . map ( |t| t. expect_ty ( ) . clean ( cx ) ) . collect ( ) ) ,
14701468
14711469 ty:: Projection ( ref data) => data. clean ( cx) ,
14721470
@@ -1699,7 +1697,7 @@ impl Clean<Variant> for hir::VariantData<'_> {
16991697
17001698impl Clean < Path > for hir:: Path < ' _ > {
17011699 fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Path {
1702- Path { res : self . res , segments : self . segments . clean ( cx) }
1700+ Path { res : self . res , segments : self . segments . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) }
17031701 }
17041702}
17051703
@@ -1709,24 +1707,24 @@ impl Clean<GenericArgs> for hir::GenericArgs<'_> {
17091707 let output = self . bindings [ 0 ] . ty ( ) . clean ( cx) ;
17101708 let output =
17111709 if output != Type :: Tuple ( Vec :: new ( ) ) { Some ( Box :: new ( output) ) } else { None } ;
1712- GenericArgs :: Parenthesized { inputs : self . inputs ( ) . clean ( cx) , output }
1710+ let inputs = self . inputs ( ) . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ;
1711+ GenericArgs :: Parenthesized { inputs, output }
17131712 } else {
1714- GenericArgs :: AngleBracketed {
1715- args : self
1716- . args
1717- . iter ( )
1718- . map ( |arg| match arg {
1719- hir:: GenericArg :: Lifetime ( lt) if !lt. is_elided ( ) => {
1720- GenericArg :: Lifetime ( lt. clean ( cx) )
1721- }
1722- hir:: GenericArg :: Lifetime ( _) => GenericArg :: Lifetime ( Lifetime :: elided ( ) ) ,
1723- hir:: GenericArg :: Type ( ty) => GenericArg :: Type ( ty. clean ( cx) ) ,
1724- hir:: GenericArg :: Const ( ct) => GenericArg :: Const ( Box :: new ( ct. clean ( cx) ) ) ,
1725- hir:: GenericArg :: Infer ( _inf) => GenericArg :: Infer ,
1726- } )
1727- . collect ( ) ,
1728- bindings : self . bindings . clean ( cx) ,
1729- }
1713+ let args = self
1714+ . args
1715+ . iter ( )
1716+ . map ( |arg| match arg {
1717+ hir:: GenericArg :: Lifetime ( lt) if !lt. is_elided ( ) => {
1718+ GenericArg :: Lifetime ( lt. clean ( cx) )
1719+ }
1720+ hir:: GenericArg :: Lifetime ( _) => GenericArg :: Lifetime ( Lifetime :: elided ( ) ) ,
1721+ hir:: GenericArg :: Type ( ty) => GenericArg :: Type ( ty. clean ( cx) ) ,
1722+ hir:: GenericArg :: Const ( ct) => GenericArg :: Const ( Box :: new ( ct. clean ( cx) ) ) ,
1723+ hir:: GenericArg :: Infer ( _inf) => GenericArg :: Infer ,
1724+ } )
1725+ . collect ( ) ;
1726+ let bindings = self . bindings . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ;
1727+ GenericArgs :: AngleBracketed { args, bindings }
17301728 }
17311729 }
17321730}
@@ -1740,7 +1738,9 @@ impl Clean<PathSegment> for hir::PathSegment<'_> {
17401738impl Clean < BareFunctionDecl > for hir:: BareFnTy < ' _ > {
17411739 fn clean ( & self , cx : & mut DocContext < ' _ > ) -> BareFunctionDecl {
17421740 let ( generic_params, decl) = enter_impl_trait ( cx, |cx| {
1743- ( self . generic_params . clean ( cx) , ( & * self . decl , self . param_names ) . clean ( cx) )
1741+ let generic_params = self . generic_params . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ;
1742+ let decl = ( self . decl , self . param_names ) . clean ( cx) ;
1743+ ( generic_params, decl)
17441744 } ) ;
17451745 BareFunctionDecl { unsafety : self . unsafety , abi : self . abi , decl, generic_params }
17461746 }
@@ -1763,7 +1763,7 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) {
17631763 kind : ConstantKind :: Local { body : body_id, def_id } ,
17641764 } ) ,
17651765 ItemKind :: OpaqueTy ( ref ty) => OpaqueTyItem ( OpaqueTy {
1766- bounds : ty. bounds . clean ( cx) ,
1766+ bounds : ty. bounds . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
17671767 generics : ty. generics . clean ( cx) ,
17681768 } ) ,
17691769 ItemKind :: TyAlias ( hir_ty, ref generics) => {
@@ -1785,17 +1785,17 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) {
17851785 } ) ,
17861786 ItemKind :: TraitAlias ( ref generics, bounds) => TraitAliasItem ( TraitAlias {
17871787 generics : generics. clean ( cx) ,
1788- bounds : bounds. clean ( cx) ,
1788+ bounds : bounds. iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
17891789 } ) ,
17901790 ItemKind :: Union ( ref variant_data, ref generics) => UnionItem ( Union {
17911791 generics : generics. clean ( cx) ,
1792- fields : variant_data. fields ( ) . clean ( cx) ,
1792+ fields : variant_data. fields ( ) . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
17931793 fields_stripped : false ,
17941794 } ) ,
17951795 ItemKind :: Struct ( ref variant_data, ref generics) => StructItem ( Struct {
17961796 struct_type : CtorKind :: from_hir ( variant_data) ,
17971797 generics : generics. clean ( cx) ,
1798- fields : variant_data. fields ( ) . clean ( cx) ,
1798+ fields : variant_data. fields ( ) . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
17991799 fields_stripped : false ,
18001800 } ) ,
18011801 ItemKind :: Impl ( ref impl_) => return clean_impl ( impl_, item. hir_id ( ) , cx) ,
@@ -1815,7 +1815,7 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) {
18151815 unsafety,
18161816 items,
18171817 generics : generics. clean ( cx) ,
1818- bounds : bounds. clean ( cx) ,
1818+ bounds : bounds. iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
18191819 is_auto : is_auto. clean ( cx) ,
18201820 } )
18211821 }
0 commit comments