@@ -55,12 +55,6 @@ crate trait Clean<T> {
55
55
fn clean ( & self , cx : & mut DocContext < ' _ > ) -> T ;
56
56
}
57
57
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
-
64
58
impl < T : Clean < U > , U > Clean < U > for & T {
65
59
fn clean ( & self , cx : & mut DocContext < ' _ > ) -> U {
66
60
( * * self ) . clean ( cx)
@@ -274,14 +268,14 @@ impl Clean<WherePredicate> for hir::WherePredicate<'_> {
274
268
. collect ( ) ;
275
269
WherePredicate :: BoundPredicate {
276
270
ty : wbp. bounded_ty . clean ( cx) ,
277
- bounds : wbp. bounds . clean ( cx) ,
271
+ bounds : wbp. bounds . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
278
272
bound_params,
279
273
}
280
274
}
281
275
282
276
hir:: WherePredicate :: RegionPredicate ( ref wrp) => WherePredicate :: RegionPredicate {
283
277
lifetime : wrp. lifetime . clean ( cx) ,
284
- bounds : wrp. bounds . clean ( cx) ,
278
+ bounds : wrp. bounds . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
285
279
} ,
286
280
287
281
hir:: WherePredicate :: EqPredicate ( ref wrp) => {
@@ -446,7 +440,7 @@ impl Clean<GenericParamDef> for hir::GenericParam<'_> {
446
440
self . name . ident ( ) . name ,
447
441
GenericParamDefKind :: Type {
448
442
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 ( ) ,
450
444
default : default. map ( |t| t. clean ( cx) ) . map ( Box :: new) ,
451
445
synthetic,
452
446
} ,
@@ -517,8 +511,10 @@ impl Clean<Generics> for hir::Generics<'_> {
517
511
}
518
512
params. extend ( impl_trait_params) ;
519
513
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
+ } ;
522
518
523
519
// Some duplicates are generated for ?Sized bounds between type params and where
524
520
// predicates. The point in here is to move the bounds definitions from type params
@@ -887,7 +883,7 @@ impl Clean<PolyTrait> for hir::PolyTraitRef<'_> {
887
883
fn clean ( & self , cx : & mut DocContext < ' _ > ) -> PolyTrait {
888
884
PolyTrait {
889
885
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 ( ) ,
891
887
}
892
888
}
893
889
}
@@ -922,7 +918,9 @@ impl Clean<Item> for hir::TraitItem<'_> {
922
918
TyMethodItem ( t)
923
919
}
924
920
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)
926
924
}
927
925
} ;
928
926
let what_rustc_thinks =
@@ -1256,7 +1254,7 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
1256
1254
let trait_def = cx. tcx . associated_item ( p. res . def_id ( ) ) . container . id ( ) ;
1257
1255
let trait_ = self :: Path {
1258
1256
res : Res :: Def ( DefKind :: Trait , trait_def) ,
1259
- segments : trait_segments. clean ( cx) ,
1257
+ segments : trait_segments. iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
1260
1258
} ;
1261
1259
register_res ( cx, trait_. res ) ;
1262
1260
Type :: QPath {
@@ -1322,11 +1320,11 @@ impl Clean<Type> for hir::Ty<'_> {
1322
1320
let length = print_const ( cx, ct. eval ( cx. tcx , param_env) ) ;
1323
1321
Array ( box ty. clean ( cx) , length)
1324
1322
}
1325
- TyKind :: Tup ( tys) => Tuple ( tys. clean ( cx) ) ,
1323
+ TyKind :: Tup ( tys) => Tuple ( tys. iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ) ,
1326
1324
TyKind :: OpaqueDef ( item_id, _) => {
1327
1325
let item = cx. tcx . hir ( ) . item ( item_id) ;
1328
1326
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 ( ) )
1330
1328
} else {
1331
1329
unreachable ! ( )
1332
1330
}
@@ -1466,7 +1464,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
1466
1464
1467
1465
DynTrait ( bounds, lifetime)
1468
1466
}
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 ( ) ) ,
1470
1468
1471
1469
ty:: Projection ( ref data) => data. clean ( cx) ,
1472
1470
@@ -1699,7 +1697,7 @@ impl Clean<Variant> for hir::VariantData<'_> {
1699
1697
1700
1698
impl Clean < Path > for hir:: Path < ' _ > {
1701
1699
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 ( ) }
1703
1701
}
1704
1702
}
1705
1703
@@ -1709,24 +1707,24 @@ impl Clean<GenericArgs> for hir::GenericArgs<'_> {
1709
1707
let output = self . bindings [ 0 ] . ty ( ) . clean ( cx) ;
1710
1708
let output =
1711
1709
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 }
1713
1712
} 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 }
1730
1728
}
1731
1729
}
1732
1730
}
@@ -1740,7 +1738,9 @@ impl Clean<PathSegment> for hir::PathSegment<'_> {
1740
1738
impl Clean < BareFunctionDecl > for hir:: BareFnTy < ' _ > {
1741
1739
fn clean ( & self , cx : & mut DocContext < ' _ > ) -> BareFunctionDecl {
1742
1740
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)
1744
1744
} ) ;
1745
1745
BareFunctionDecl { unsafety : self . unsafety , abi : self . abi , decl, generic_params }
1746
1746
}
@@ -1763,7 +1763,7 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) {
1763
1763
kind : ConstantKind :: Local { body : body_id, def_id } ,
1764
1764
} ) ,
1765
1765
ItemKind :: OpaqueTy ( ref ty) => OpaqueTyItem ( OpaqueTy {
1766
- bounds : ty. bounds . clean ( cx) ,
1766
+ bounds : ty. bounds . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
1767
1767
generics : ty. generics . clean ( cx) ,
1768
1768
} ) ,
1769
1769
ItemKind :: TyAlias ( hir_ty, ref generics) => {
@@ -1785,17 +1785,17 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) {
1785
1785
} ) ,
1786
1786
ItemKind :: TraitAlias ( ref generics, bounds) => TraitAliasItem ( TraitAlias {
1787
1787
generics : generics. clean ( cx) ,
1788
- bounds : bounds. clean ( cx) ,
1788
+ bounds : bounds. iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
1789
1789
} ) ,
1790
1790
ItemKind :: Union ( ref variant_data, ref generics) => UnionItem ( Union {
1791
1791
generics : generics. clean ( cx) ,
1792
- fields : variant_data. fields ( ) . clean ( cx) ,
1792
+ fields : variant_data. fields ( ) . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
1793
1793
fields_stripped : false ,
1794
1794
} ) ,
1795
1795
ItemKind :: Struct ( ref variant_data, ref generics) => StructItem ( Struct {
1796
1796
struct_type : CtorKind :: from_hir ( variant_data) ,
1797
1797
generics : generics. clean ( cx) ,
1798
- fields : variant_data. fields ( ) . clean ( cx) ,
1798
+ fields : variant_data. fields ( ) . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
1799
1799
fields_stripped : false ,
1800
1800
} ) ,
1801
1801
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>) {
1815
1815
unsafety,
1816
1816
items,
1817
1817
generics : generics. clean ( cx) ,
1818
- bounds : bounds. clean ( cx) ,
1818
+ bounds : bounds. iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
1819
1819
is_auto : is_auto. clean ( cx) ,
1820
1820
} )
1821
1821
}
0 commit comments