@@ -71,30 +71,29 @@ pub struct DumpCsvVisitor<'l, 'tcx: 'l> {
71
71
span : SpanUtils < ' l > ,
72
72
fmt : FmtStrs < ' l > ,
73
73
74
- cur_scope : NodeId
74
+ cur_scope : NodeId ,
75
75
}
76
76
77
77
impl < ' l , ' tcx > DumpCsvVisitor < ' l , ' tcx > {
78
78
pub fn new ( tcx : & ' l ty:: ctxt < ' tcx > ,
79
79
analysis : & ' l ty:: CrateAnalysis ,
80
- output_file : Box < File > ) -> DumpCsvVisitor < ' l , ' tcx > {
80
+ output_file : Box < File > )
81
+ -> DumpCsvVisitor < ' l , ' tcx > {
81
82
let span_utils = SpanUtils :: new ( & tcx. sess ) ;
82
83
DumpCsvVisitor {
83
84
sess : & tcx. sess ,
84
85
tcx : tcx,
85
86
save_ctxt : SaveContext :: from_span_utils ( tcx, span_utils. clone ( ) ) ,
86
87
analysis : analysis,
87
88
span : span_utils. clone ( ) ,
88
- fmt : FmtStrs :: new ( box Recorder {
89
- out : output_file,
90
- dump_spans : false ,
91
- } , span_utils) ,
92
- cur_scope : 0
89
+ fmt : FmtStrs :: new ( box Recorder { out : output_file, dump_spans : false } ,
90
+ span_utils) ,
91
+ cur_scope : 0 ,
93
92
}
94
93
}
95
94
96
- fn nest < F > ( & mut self , scope_id : NodeId , f : F ) where
97
- F : FnOnce ( & mut DumpCsvVisitor < ' l , ' tcx > ) ,
95
+ fn nest < F > ( & mut self , scope_id : NodeId , f : F )
96
+ where F : FnOnce ( & mut DumpCsvVisitor < ' l , ' tcx > )
98
97
{
99
98
let parent_scope = self . cur_scope ;
100
99
self . cur_scope = scope_id;
@@ -140,9 +139,11 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
140
139
let mut segs = vec ! ( ) ;
141
140
for ( i, ( seg, span) ) in path. segments . iter ( ) . zip ( & spans) . enumerate ( ) {
142
141
segs. push ( seg. clone ( ) ) ;
143
- let sub_path = ast:: Path { span : * span, // span for the last segment
144
- global : path. global ,
145
- segments : segs} ;
142
+ let sub_path = ast:: Path {
143
+ span : * span, // span for the last segment
144
+ global : path. global ,
145
+ segments : segs,
146
+ } ;
146
147
let qualname = if i == 0 && path. global {
147
148
format ! ( "::{}" , path_to_string( & sub_path) )
148
149
} else {
@@ -271,7 +272,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
271
272
def:: DefPrimTy ( _) => {
272
273
self . sess . span_bug ( span, & format ! ( "lookup_def_kind for unexpected item: {:?}" ,
273
274
def) ) ;
274
- } ,
275
+ }
275
276
}
276
277
}
277
278
@@ -357,9 +358,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
357
358
}
358
359
}
359
360
360
- fn process_struct_field_def ( & mut self ,
361
- field : & ast:: StructField ,
362
- parent_id : NodeId ) {
361
+ fn process_struct_field_def ( & mut self , field : & ast:: StructField , parent_id : NodeId ) {
363
362
let field_data = self . save_ctxt . get_field_data ( field, parent_id) ;
364
363
if let Some ( field_data) = field_data {
365
364
self . fmt . field_str ( field. span ,
@@ -374,7 +373,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
374
373
375
374
// Dump generic params bindings, then visit_generics
376
375
fn process_generic_params ( & mut self ,
377
- generics : & ast:: Generics ,
376
+ generics : & ast:: Generics ,
378
377
full_span : Span ,
379
378
prefix : & str ,
380
379
id : NodeId ) {
@@ -427,11 +426,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
427
426
self . nest ( item. id , |v| v. visit_block ( & body) ) ;
428
427
}
429
428
430
- fn process_static_or_const_item ( & mut self ,
431
- item : & ast:: Item ,
432
- typ : & ast:: Ty ,
433
- expr : & ast:: Expr )
434
- {
429
+ fn process_static_or_const_item ( & mut self , item : & ast:: Item , typ : & ast:: Ty , expr : & ast:: Expr ) {
435
430
let var_data = self . save_ctxt . get_item_data ( item) ;
436
431
down_cast_data ! ( var_data, VariableData , self , item. span) ;
437
432
self . fmt . static_str ( item. span ,
@@ -452,8 +447,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
452
447
ident : & ast:: Ident ,
453
448
span : Span ,
454
449
typ : & ast:: Ty ,
455
- expr : & ast:: Expr )
456
- {
450
+ expr : & ast:: Expr ) {
457
451
let qualname = format ! ( "::{}" , self . tcx. map. path_to_string( id) ) ;
458
452
459
453
let sub_span = self . span . sub_span_after_keyword ( span,
@@ -641,8 +635,8 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
641
635
sub_span,
642
636
id,
643
637
item. id ) ;
644
- } ,
645
- None => ( )
638
+ }
639
+ None => ( ) ,
646
640
}
647
641
}
648
642
@@ -653,8 +647,8 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
653
647
}
654
648
}
655
649
656
- fn process_mod ( & mut self ,
657
- item : & ast:: Item ) { // The module in question, represented as an item.
650
+ // `item` is the module in question, represented as an item.
651
+ fn process_mod ( & mut self , item : & ast:: Item ) {
658
652
let mod_data = self . save_ctxt . get_item_data ( item) ;
659
653
down_cast_data ! ( mod_data, ModData , self , item. span) ;
660
654
self . fmt . mod_str ( item. span ,
@@ -665,10 +659,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
665
659
& mod_data. filename ) ;
666
660
}
667
661
668
- fn process_path ( & mut self ,
669
- id : NodeId ,
670
- path : & ast:: Path ,
671
- ref_kind : Option < recorder:: Row > ) {
662
+ fn process_path ( & mut self , id : NodeId , path : & ast:: Path , ref_kind : Option < recorder:: Row > ) {
672
663
if generated_code ( path. span ) {
673
664
return ;
674
665
}
@@ -737,7 +728,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
737
728
def:: DefStruct ( _) |
738
729
def:: DefVariant ( ..) |
739
730
def:: DefFn ( ..) => self . write_sub_paths_truncated ( path, false ) ,
740
- _ => { } ,
731
+ _ => { }
741
732
}
742
733
}
743
734
@@ -783,9 +774,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
783
774
visit:: walk_expr_opt ( self , base)
784
775
}
785
776
786
- fn process_method_call ( & mut self ,
787
- ex : & ast:: Expr ,
788
- args : & Vec < P < ast:: Expr > > ) {
777
+ fn process_method_call ( & mut self , ex : & ast:: Expr , args : & Vec < P < ast:: Expr > > ) {
789
778
if let Some ( call_data) = self . save_ctxt . get_expr_data ( ex) {
790
779
down_cast_data ! ( call_data, MethodCallData , self , ex. span) ;
791
780
self . fmt . meth_call_str ( ex. span ,
@@ -799,7 +788,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
799
788
visit:: walk_exprs ( self , & args) ;
800
789
}
801
790
802
- fn process_pat ( & mut self , p : & ast:: Pat ) {
791
+ fn process_pat ( & mut self , p : & ast:: Pat ) {
803
792
if generated_code ( p. span ) {
804
793
return ;
805
794
}
@@ -827,7 +816,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
827
816
self . visit_pat ( & field. pat ) ;
828
817
}
829
818
}
830
- _ => visit:: walk_pat ( self , p)
819
+ _ => visit:: walk_pat ( self , p) ,
831
820
}
832
821
}
833
822
}
@@ -851,10 +840,10 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
851
840
sub_span,
852
841
def_id,
853
842
self . cur_scope ) ,
854
- None => { } ,
843
+ None => { }
855
844
}
856
845
Some ( def_id)
857
- } ,
846
+ }
858
847
None => None ,
859
848
} ;
860
849
@@ -902,20 +891,19 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
902
891
match plid. node {
903
892
ast:: PathListIdent { id, .. } => {
904
893
match self . lookup_type_ref ( id) {
905
- Some ( def_id) =>
906
- match self . lookup_def_kind ( id, plid. span ) {
907
- Some ( kind) => {
908
- self . fmt . ref_str (
894
+ Some ( def_id) => match self . lookup_def_kind ( id, plid. span ) {
895
+ Some ( kind) => {
896
+ self . fmt . ref_str (
909
897
kind, plid. span ,
910
898
Some ( plid. span ) ,
911
899
def_id, self . cur_scope ) ;
912
- }
913
- None => ( )
914
- } ,
915
- None => ( )
900
+ }
901
+ None => ( ) ,
902
+ } ,
903
+ None => ( ) ,
916
904
}
917
- } ,
918
- ast:: PathListMod { .. } => ( )
905
+ }
906
+ ast:: PathListMod { .. } => ( ) ,
919
907
}
920
908
}
921
909
@@ -978,7 +966,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
978
966
979
967
self . visit_ty ( & * * ty) ;
980
968
self . process_generic_params ( ty_params, item. span , & qualname, item. id ) ;
981
- } ,
969
+ }
982
970
ast:: ItemMac ( _) => ( ) ,
983
971
_ => visit:: walk_item ( self , item) ,
984
972
}
@@ -1048,14 +1036,14 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
1048
1036
sub_span,
1049
1037
id,
1050
1038
self . cur_scope ) ;
1051
- } ,
1052
- None => ( )
1039
+ }
1040
+ None => ( ) ,
1053
1041
}
1054
1042
1055
1043
self . write_sub_paths_truncated ( path, false ) ;
1056
1044
1057
1045
visit:: walk_path ( self , path) ;
1058
- } ,
1046
+ }
1059
1047
_ => visit:: walk_ty ( self , t) ,
1060
1048
}
1061
1049
}
@@ -1101,7 +1089,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
1101
1089
field_data. ref_id ,
1102
1090
field_data. scope ) ;
1103
1091
}
1104
- } ,
1092
+ }
1105
1093
ast:: ExprTupField ( ref sub_ex, idx) => {
1106
1094
if generated_code ( sub_ex. span ) {
1107
1095
return
@@ -1125,7 +1113,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
1125
1113
& format ! ( "Expected struct or tuple \
1126
1114
type, found {:?}", ty) ) ,
1127
1115
}
1128
- } ,
1116
+ }
1129
1117
ast:: ExprClosure ( _, ref decl, ref body) => {
1130
1118
if generated_code ( body. span ) {
1131
1119
return
@@ -1146,7 +1134,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
1146
1134
1147
1135
// walk the body
1148
1136
self . nest ( ex. id , |v| v. visit_block ( & * * body) ) ;
1149
- } ,
1137
+ }
1150
1138
_ => {
1151
1139
visit:: walk_expr ( self , ex)
1152
1140
}
@@ -1182,7 +1170,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
1182
1170
}
1183
1171
let def = def_map. get ( & id) . unwrap ( ) . full_def ( ) ;
1184
1172
match def {
1185
- def:: DefLocal ( id) => {
1173
+ def:: DefLocal ( id) => {
1186
1174
let value = if immut == ast:: MutImmutable {
1187
1175
self . span . snippet ( p. span ) . to_string ( )
1188
1176
} else {
@@ -1205,7 +1193,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
1205
1193
def:: DefConst ( ..) |
1206
1194
def:: DefAssociatedConst ( ..) => { }
1207
1195
_ => error ! ( "unexpected definition kind when processing collected paths: {:?}" ,
1208
- def)
1196
+ def) ,
1209
1197
}
1210
1198
}
1211
1199
0 commit comments