@@ -29,6 +29,7 @@ use std;
2929use doctree;
3030use visit_ast;
3131use std:: local_data;
32+ use std:: vec_ng:: Vec ;
3233
3334pub trait Clean < T > {
3435 fn clean ( & self ) -> T ;
@@ -39,6 +40,13 @@ impl<T: Clean<U>, U> Clean<~[U]> for ~[T] {
3940 self . iter ( ) . map ( |x| x. clean ( ) ) . collect ( )
4041 }
4142}
43+
44+ impl < T : Clean < U > , U > Clean < Vec < U > > for Vec < T > {
45+ fn clean ( & self ) -> Vec < U > {
46+ self . iter ( ) . map ( |x| x. clean ( ) ) . collect ( )
47+ }
48+ }
49+
4250impl < T : Clean < U > , U > Clean < U > for @T {
4351 fn clean ( & self ) -> U {
4452 ( * * self ) . clean ( )
@@ -54,10 +62,10 @@ impl<T: Clean<U>, U> Clean<Option<U>> for Option<T> {
5462 }
5563}
5664
57- impl < T : Clean < U > , U > Clean < ~ [ U ] > for syntax:: opt_vec:: OptVec < T > {
58- fn clean ( & self ) -> ~ [ U ] {
65+ impl < T : Clean < U > , U > Clean < Vec < U > > for syntax:: opt_vec:: OptVec < T > {
66+ fn clean ( & self ) -> Vec < U > {
5967 match self {
60- & syntax:: opt_vec:: Empty => ~ [ ] ,
68+ & syntax:: opt_vec:: Empty => Vec :: new ( ) ,
6169 & syntax:: opt_vec:: Vec ( ref v) => v. clean ( )
6270 }
6371 }
@@ -196,6 +204,25 @@ impl Clean<Item> for doctree::Module {
196204 } else {
197205 ~""
198206 } ;
207+ let mut foreigns = ~[ ] ;
208+ for subforeigns in self . foreigns . clean ( ) . move_iter ( ) {
209+ for foreign in subforeigns. move_iter ( ) {
210+ foreigns. push ( foreign)
211+ }
212+ }
213+ let items: ~[ ~[ Item ] ] = ~[
214+ self . structs . clean ( ) . move_iter ( ) . collect ( ) ,
215+ self . enums . clean ( ) . move_iter ( ) . collect ( ) ,
216+ self . fns . clean ( ) . move_iter ( ) . collect ( ) ,
217+ foreigns,
218+ self . mods . clean ( ) . move_iter ( ) . collect ( ) ,
219+ self . typedefs . clean ( ) . move_iter ( ) . collect ( ) ,
220+ self . statics . clean ( ) . move_iter ( ) . collect ( ) ,
221+ self . traits . clean ( ) . move_iter ( ) . collect ( ) ,
222+ self . impls . clean ( ) . move_iter ( ) . collect ( ) ,
223+ self . view_items . clean ( ) . move_iter ( ) . collect ( ) ,
224+ self . macros . clean ( ) . move_iter ( ) . collect ( )
225+ ] ;
199226 Item {
200227 name : Some ( name) ,
201228 attrs : self . attrs . clean ( ) ,
@@ -204,12 +231,7 @@ impl Clean<Item> for doctree::Module {
204231 id : self . id ,
205232 inner : ModuleItem ( Module {
206233 is_crate : self . is_crate ,
207- items : [ self . structs . clean ( ) , self . enums . clean ( ) ,
208- self . fns . clean ( ) , self . foreigns . clean ( ) . concat_vec ( ) ,
209- self . mods . clean ( ) , self . typedefs . clean ( ) ,
210- self . statics . clean ( ) , self . traits . clean ( ) ,
211- self . impls . clean ( ) , self . view_items . clean ( ) ,
212- self . macros . clean ( ) ] . concat_vec ( )
234+ items : items. concat_vec ( ) ,
213235 } )
214236 }
215237 }
@@ -227,7 +249,7 @@ impl Clean<Attribute> for ast::MetaItem {
227249 match self . node {
228250 ast:: MetaWord ( ref s) => Word ( s. get ( ) . to_owned ( ) ) ,
229251 ast:: MetaList ( ref s, ref l) => {
230- List ( s. get ( ) . to_owned ( ) , l. clean ( ) )
252+ List ( s. get ( ) . to_owned ( ) , l. clean ( ) . move_iter ( ) . collect ( ) )
231253 }
232254 ast:: MetaNameValue ( ref s, ref v) => {
233255 NameValue ( s. get ( ) . to_owned ( ) , lit_to_str ( v) )
@@ -276,7 +298,7 @@ impl Clean<TyParam> for ast::TyParam {
276298 TyParam {
277299 name : self . ident . clean ( ) ,
278300 id : self . id ,
279- bounds : self . bounds . clean ( ) ,
301+ bounds : self . bounds . clean ( ) . move_iter ( ) . collect ( ) ,
280302 }
281303 }
282304}
@@ -323,8 +345,8 @@ pub struct Generics {
323345impl Clean < Generics > for ast:: Generics {
324346 fn clean ( & self ) -> Generics {
325347 Generics {
326- lifetimes : self . lifetimes . clean ( ) ,
327- type_params : self . ty_params . clean ( ) ,
348+ lifetimes : self . lifetimes . clean ( ) . move_iter ( ) . collect ( ) ,
349+ type_params : self . ty_params . clean ( ) . move_iter ( ) . collect ( ) ,
328350 }
329351 }
330352}
@@ -353,7 +375,7 @@ impl Clean<Item> for ast::Method {
353375 } ;
354376 Item {
355377 name : Some ( self . ident . clean ( ) ) ,
356- attrs : self . attrs . clean ( ) ,
378+ attrs : self . attrs . clean ( ) . move_iter ( ) . collect ( ) ,
357379 source : self . span . clean ( ) ,
358380 id : self . id . clone ( ) ,
359381 visibility : self . vis . clean ( ) ,
@@ -391,7 +413,7 @@ impl Clean<Item> for ast::TypeMethod {
391413 } ;
392414 Item {
393415 name : Some ( self . ident . clean ( ) ) ,
394- attrs : self . attrs . clean ( ) ,
416+ attrs : self . attrs . clean ( ) . move_iter ( ) . collect ( ) ,
395417 source : self . span . clean ( ) ,
396418 id : self . id ,
397419 visibility : None ,
@@ -464,12 +486,12 @@ impl Clean<ClosureDecl> for ast::ClosureTy {
464486 ClosureDecl {
465487 sigil : self . sigil ,
466488 region : self . region . clean ( ) ,
467- lifetimes : self . lifetimes . clean ( ) ,
489+ lifetimes : self . lifetimes . clean ( ) . move_iter ( ) . collect ( ) ,
468490 decl : self . decl . clean ( ) ,
469491 onceness : self . onceness ,
470492 purity : self . purity ,
471493 bounds : match self . bounds {
472- Some ( ref x) => x. clean ( ) ,
494+ Some ( ref x) => x. clean ( ) . move_iter ( ) . collect ( ) ,
473495 None => ~[ ]
474496 } ,
475497 }
@@ -673,8 +695,11 @@ impl Clean<Type> for ast::Ty {
673695 TyFixedLengthVec ( ty, ref e) => FixedVector ( ~ty. clean ( ) ,
674696 e. span . to_src ( ) ) ,
675697 TyTup ( ref tys) => Tuple ( tys. iter ( ) . map ( |x| x. clean ( ) ) . collect ( ) ) ,
676- TyPath ( ref p, ref tpbs, id) =>
677- resolve_type ( p. clean ( ) , tpbs. clean ( ) , id) ,
698+ TyPath ( ref p, ref tpbs, id) => {
699+ resolve_type ( p. clean ( ) ,
700+ tpbs. clean ( ) . map ( |x| x. move_iter ( ) . collect ( ) ) ,
701+ id)
702+ }
678703 TyClosure ( ref c) => Closure ( ~c. clean ( ) ) ,
679704 TyBareFn ( ref barefn) => BareFunction ( ~barefn. clean ( ) ) ,
680705 TyBot => Bottom ,
@@ -696,7 +721,7 @@ impl Clean<Item> for ast::StructField {
696721 } ;
697722 Item {
698723 name : name. clean ( ) ,
699- attrs : self . node . attrs . clean ( ) ,
724+ attrs : self . node . attrs . clean ( ) . move_iter ( ) . collect ( ) ,
700725 source : self . span . clean ( ) ,
701726 visibility : vis,
702727 id : self . node . id ,
@@ -755,7 +780,7 @@ impl Clean<VariantStruct> for syntax::ast::StructDef {
755780 fn clean ( & self ) -> VariantStruct {
756781 VariantStruct {
757782 struct_type : doctree:: struct_type_from_def ( self ) ,
758- fields : self . fields . clean ( ) ,
783+ fields : self . fields . clean ( ) . move_iter ( ) . collect ( ) ,
759784 fields_stripped : false ,
760785 }
761786 }
@@ -862,7 +887,7 @@ impl Clean<Path> for ast::Path {
862887 fn clean ( & self ) -> Path {
863888 Path {
864889 global : self . global ,
865- segments : self . segments . clean ( )
890+ segments : self . segments . clean ( ) . move_iter ( ) . collect ( ) ,
866891 }
867892 }
868893}
@@ -878,8 +903,8 @@ impl Clean<PathSegment> for ast::PathSegment {
878903 fn clean ( & self ) -> PathSegment {
879904 PathSegment {
880905 name : self . identifier . clean ( ) ,
881- lifetimes : self . lifetimes . clean ( ) ,
882- types : self . types . clean ( )
906+ lifetimes : self . lifetimes . clean ( ) . move_iter ( ) . collect ( ) ,
907+ types : self . types . clean ( ) . move_iter ( ) . collect ( )
883908 }
884909 }
885910}
@@ -941,7 +966,7 @@ impl Clean<BareFunctionDecl> for ast::BareFnTy {
941966 BareFunctionDecl {
942967 purity : self . purity ,
943968 generics : Generics {
944- lifetimes : self . lifetimes . clean ( ) ,
969+ lifetimes : self . lifetimes . clean ( ) . move_iter ( ) . collect ( ) ,
945970 type_params : ~[ ] ,
946971 } ,
947972 decl : self . decl . clean ( ) ,
@@ -1028,7 +1053,7 @@ impl Clean<Item> for ast::ViewItem {
10281053 fn clean ( & self ) -> Item {
10291054 Item {
10301055 name : None ,
1031- attrs : self . attrs . clean ( ) ,
1056+ attrs : self . attrs . clean ( ) . move_iter ( ) . collect ( ) ,
10321057 source : self . span . clean ( ) ,
10331058 id : 0 ,
10341059 visibility : self . vis . clean ( ) ,
@@ -1055,7 +1080,9 @@ impl Clean<ViewItemInner> for ast::ViewItem_ {
10551080 } ;
10561081 ExternMod ( i. clean ( ) , string, * id)
10571082 }
1058- & ast:: ViewItemUse ( ref vp) => Import ( vp. clean ( ) )
1083+ & ast:: ViewItemUse ( ref vp) => {
1084+ Import ( vp. clean ( ) . move_iter ( ) . collect ( ) )
1085+ }
10591086 }
10601087 }
10611088}
@@ -1083,8 +1110,10 @@ impl Clean<ViewPath> for ast::ViewPath {
10831110 SimpleImport ( i. clean ( ) , resolve_use_source ( p. clean ( ) , id) ) ,
10841111 ast:: ViewPathGlob ( ref p, id) =>
10851112 GlobImport ( resolve_use_source ( p. clean ( ) , id) ) ,
1086- ast:: ViewPathList ( ref p, ref pl, id) =>
1087- ImportList ( resolve_use_source ( p. clean ( ) , id) , pl. clean ( ) ) ,
1113+ ast:: ViewPathList ( ref p, ref pl, id) => {
1114+ ImportList ( resolve_use_source ( p. clean ( ) , id) ,
1115+ pl. clean ( ) . move_iter ( ) . collect ( ) )
1116+ }
10881117 }
10891118 }
10901119}
@@ -1104,8 +1133,8 @@ impl Clean<ViewListIdent> for ast::PathListIdent {
11041133 }
11051134}
11061135
1107- impl Clean < ~ [ Item ] > for ast:: ForeignMod {
1108- fn clean ( & self ) -> ~ [ Item ] {
1136+ impl Clean < Vec < Item > > for ast:: ForeignMod {
1137+ fn clean ( & self ) -> Vec < Item > {
11091138 self . items . clean ( )
11101139 }
11111140}
@@ -1130,7 +1159,7 @@ impl Clean<Item> for ast::ForeignItem {
11301159 } ;
11311160 Item {
11321161 name : Some ( self . ident . clean ( ) ) ,
1133- attrs : self . attrs . clean ( ) ,
1162+ attrs : self . attrs . clean ( ) . move_iter ( ) . collect ( ) ,
11341163 source : self . span . clean ( ) ,
11351164 id : self . id ,
11361165 visibility : self . vis . clean ( ) ,
0 commit comments