@@ -29,6 +29,7 @@ use std;
29
29
use doctree;
30
30
use visit_ast;
31
31
use std:: local_data;
32
+ use std:: vec_ng:: Vec ;
32
33
33
34
pub trait Clean < T > {
34
35
fn clean ( & self ) -> T ;
@@ -39,6 +40,13 @@ impl<T: Clean<U>, U> Clean<~[U]> for ~[T] {
39
40
self . iter ( ) . map ( |x| x. clean ( ) ) . collect ( )
40
41
}
41
42
}
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
+
42
50
impl < T : Clean < U > , U > Clean < U > for @T {
43
51
fn clean ( & self ) -> U {
44
52
( * * self ) . clean ( )
@@ -54,10 +62,10 @@ impl<T: Clean<U>, U> Clean<Option<U>> for Option<T> {
54
62
}
55
63
}
56
64
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 > {
59
67
match self {
60
- & syntax:: opt_vec:: Empty => ~ [ ] ,
68
+ & syntax:: opt_vec:: Empty => Vec :: new ( ) ,
61
69
& syntax:: opt_vec:: Vec ( ref v) => v. clean ( )
62
70
}
63
71
}
@@ -196,6 +204,25 @@ impl Clean<Item> for doctree::Module {
196
204
} else {
197
205
~""
198
206
} ;
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
+ ] ;
199
226
Item {
200
227
name : Some ( name) ,
201
228
attrs : self . attrs . clean ( ) ,
@@ -204,12 +231,7 @@ impl Clean<Item> for doctree::Module {
204
231
id : self . id ,
205
232
inner : ModuleItem ( Module {
206
233
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 ( ) ,
213
235
} )
214
236
}
215
237
}
@@ -227,7 +249,7 @@ impl Clean<Attribute> for ast::MetaItem {
227
249
match self . node {
228
250
ast:: MetaWord ( ref s) => Word ( s. get ( ) . to_owned ( ) ) ,
229
251
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 ( ) )
231
253
}
232
254
ast:: MetaNameValue ( ref s, ref v) => {
233
255
NameValue ( s. get ( ) . to_owned ( ) , lit_to_str ( v) )
@@ -276,7 +298,7 @@ impl Clean<TyParam> for ast::TyParam {
276
298
TyParam {
277
299
name : self . ident . clean ( ) ,
278
300
id : self . id ,
279
- bounds : self . bounds . clean ( ) ,
301
+ bounds : self . bounds . clean ( ) . move_iter ( ) . collect ( ) ,
280
302
}
281
303
}
282
304
}
@@ -323,8 +345,8 @@ pub struct Generics {
323
345
impl Clean < Generics > for ast:: Generics {
324
346
fn clean ( & self ) -> Generics {
325
347
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 ( ) ,
328
350
}
329
351
}
330
352
}
@@ -353,7 +375,7 @@ impl Clean<Item> for ast::Method {
353
375
} ;
354
376
Item {
355
377
name : Some ( self . ident . clean ( ) ) ,
356
- attrs : self . attrs . clean ( ) ,
378
+ attrs : self . attrs . clean ( ) . move_iter ( ) . collect ( ) ,
357
379
source : self . span . clean ( ) ,
358
380
id : self . id . clone ( ) ,
359
381
visibility : self . vis . clean ( ) ,
@@ -391,7 +413,7 @@ impl Clean<Item> for ast::TypeMethod {
391
413
} ;
392
414
Item {
393
415
name : Some ( self . ident . clean ( ) ) ,
394
- attrs : self . attrs . clean ( ) ,
416
+ attrs : self . attrs . clean ( ) . move_iter ( ) . collect ( ) ,
395
417
source : self . span . clean ( ) ,
396
418
id : self . id ,
397
419
visibility : None ,
@@ -464,12 +486,12 @@ impl Clean<ClosureDecl> for ast::ClosureTy {
464
486
ClosureDecl {
465
487
sigil : self . sigil ,
466
488
region : self . region . clean ( ) ,
467
- lifetimes : self . lifetimes . clean ( ) ,
489
+ lifetimes : self . lifetimes . clean ( ) . move_iter ( ) . collect ( ) ,
468
490
decl : self . decl . clean ( ) ,
469
491
onceness : self . onceness ,
470
492
purity : self . purity ,
471
493
bounds : match self . bounds {
472
- Some ( ref x) => x. clean ( ) ,
494
+ Some ( ref x) => x. clean ( ) . move_iter ( ) . collect ( ) ,
473
495
None => ~[ ]
474
496
} ,
475
497
}
@@ -673,8 +695,11 @@ impl Clean<Type> for ast::Ty {
673
695
TyFixedLengthVec ( ty, ref e) => FixedVector ( ~ty. clean ( ) ,
674
696
e. span . to_src ( ) ) ,
675
697
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
+ }
678
703
TyClosure ( ref c) => Closure ( ~c. clean ( ) ) ,
679
704
TyBareFn ( ref barefn) => BareFunction ( ~barefn. clean ( ) ) ,
680
705
TyBot => Bottom ,
@@ -696,7 +721,7 @@ impl Clean<Item> for ast::StructField {
696
721
} ;
697
722
Item {
698
723
name : name. clean ( ) ,
699
- attrs : self . node . attrs . clean ( ) ,
724
+ attrs : self . node . attrs . clean ( ) . move_iter ( ) . collect ( ) ,
700
725
source : self . span . clean ( ) ,
701
726
visibility : vis,
702
727
id : self . node . id ,
@@ -755,7 +780,7 @@ impl Clean<VariantStruct> for syntax::ast::StructDef {
755
780
fn clean ( & self ) -> VariantStruct {
756
781
VariantStruct {
757
782
struct_type : doctree:: struct_type_from_def ( self ) ,
758
- fields : self . fields . clean ( ) ,
783
+ fields : self . fields . clean ( ) . move_iter ( ) . collect ( ) ,
759
784
fields_stripped : false ,
760
785
}
761
786
}
@@ -862,7 +887,7 @@ impl Clean<Path> for ast::Path {
862
887
fn clean ( & self ) -> Path {
863
888
Path {
864
889
global : self . global ,
865
- segments : self . segments . clean ( )
890
+ segments : self . segments . clean ( ) . move_iter ( ) . collect ( ) ,
866
891
}
867
892
}
868
893
}
@@ -878,8 +903,8 @@ impl Clean<PathSegment> for ast::PathSegment {
878
903
fn clean ( & self ) -> PathSegment {
879
904
PathSegment {
880
905
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 ( )
883
908
}
884
909
}
885
910
}
@@ -941,7 +966,7 @@ impl Clean<BareFunctionDecl> for ast::BareFnTy {
941
966
BareFunctionDecl {
942
967
purity : self . purity ,
943
968
generics : Generics {
944
- lifetimes : self . lifetimes . clean ( ) ,
969
+ lifetimes : self . lifetimes . clean ( ) . move_iter ( ) . collect ( ) ,
945
970
type_params : ~[ ] ,
946
971
} ,
947
972
decl : self . decl . clean ( ) ,
@@ -1028,7 +1053,7 @@ impl Clean<Item> for ast::ViewItem {
1028
1053
fn clean ( & self ) -> Item {
1029
1054
Item {
1030
1055
name : None ,
1031
- attrs : self . attrs . clean ( ) ,
1056
+ attrs : self . attrs . clean ( ) . move_iter ( ) . collect ( ) ,
1032
1057
source : self . span . clean ( ) ,
1033
1058
id : 0 ,
1034
1059
visibility : self . vis . clean ( ) ,
@@ -1055,7 +1080,9 @@ impl Clean<ViewItemInner> for ast::ViewItem_ {
1055
1080
} ;
1056
1081
ExternMod ( i. clean ( ) , string, * id)
1057
1082
}
1058
- & ast:: ViewItemUse ( ref vp) => Import ( vp. clean ( ) )
1083
+ & ast:: ViewItemUse ( ref vp) => {
1084
+ Import ( vp. clean ( ) . move_iter ( ) . collect ( ) )
1085
+ }
1059
1086
}
1060
1087
}
1061
1088
}
@@ -1083,8 +1110,10 @@ impl Clean<ViewPath> for ast::ViewPath {
1083
1110
SimpleImport ( i. clean ( ) , resolve_use_source ( p. clean ( ) , id) ) ,
1084
1111
ast:: ViewPathGlob ( ref p, id) =>
1085
1112
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
+ }
1088
1117
}
1089
1118
}
1090
1119
}
@@ -1104,8 +1133,8 @@ impl Clean<ViewListIdent> for ast::PathListIdent {
1104
1133
}
1105
1134
}
1106
1135
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 > {
1109
1138
self . items . clean ( )
1110
1139
}
1111
1140
}
@@ -1130,7 +1159,7 @@ impl Clean<Item> for ast::ForeignItem {
1130
1159
} ;
1131
1160
Item {
1132
1161
name : Some ( self . ident . clean ( ) ) ,
1133
- attrs : self . attrs . clean ( ) ,
1162
+ attrs : self . attrs . clean ( ) . move_iter ( ) . collect ( ) ,
1134
1163
source : self . span . clean ( ) ,
1135
1164
id : self . id ,
1136
1165
visibility : self . vis . clean ( ) ,
0 commit comments