@@ -508,7 +508,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
508
508
self . process_formals ( & decl. inputs , & fn_data. qualname ) ;
509
509
self . process_generic_params ( ty_params, item. span , & fn_data. qualname , item. id ) ;
510
510
} else {
511
- unreachable ! ( ) ;
511
+ self . sess . span_bug ( item . span , "expected FunctionData" ) ;
512
512
}
513
513
514
514
for arg in & decl. inputs {
@@ -538,7 +538,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
538
538
& var_data. type_value ,
539
539
var_data. scope ) ;
540
540
} else {
541
- unreachable ! ( ) ;
541
+ self . sess . span_bug ( item . span , "expected VariableData" ) ;
542
542
}
543
543
544
544
self . visit_ty ( & typ) ;
@@ -768,22 +768,18 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
768
768
}
769
769
770
770
fn process_mod ( & mut self ,
771
- item : & ast:: Item , // The module in question, represented as an item.
772
- m : & ast:: Mod ) {
773
- let qualname = format ! ( "::{}" , self . analysis. ty_cx. map. path_to_string( item. id) ) ;
774
-
775
- let cm = self . sess . codemap ( ) ;
776
- let filename = cm. span_to_filename ( m. inner ) ;
777
-
778
- let sub_span = self . span . sub_span_after_keyword ( item. span , keywords:: Mod ) ;
779
- self . fmt . mod_str ( item. span ,
780
- sub_span,
781
- item. id ,
782
- & qualname[ ..] ,
783
- self . cur_scope ,
784
- & filename[ ..] ) ;
785
-
786
- self . nest ( item. id , |v| visit:: walk_mod ( v, m) ) ;
771
+ item : & ast:: Item ) { // The module in question, represented as an item.
772
+ let mod_data = self . save_ctxt . get_item_data ( item) ;
773
+ if let super :: Data :: ModData ( mod_data) = mod_data {
774
+ self . fmt . mod_str ( item. span ,
775
+ Some ( mod_data. span ) ,
776
+ mod_data. id ,
777
+ & mod_data. qualname ,
778
+ mod_data. scope ,
779
+ & mod_data. filename ) ;
780
+ } else {
781
+ self . sess . span_bug ( item. span , "expected ModData" ) ;
782
+ }
787
783
}
788
784
789
785
fn process_path ( & mut self ,
@@ -1188,7 +1184,10 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
1188
1184
}
1189
1185
ast:: ItemTrait ( _, ref generics, ref trait_refs, ref methods) =>
1190
1186
self . process_trait ( item, generics, trait_refs, methods) ,
1191
- ast:: ItemMod ( ref m) => self . process_mod ( item, m) ,
1187
+ ast:: ItemMod ( ref m) => {
1188
+ self . process_mod ( item) ;
1189
+ self . nest ( item. id , |v| visit:: walk_mod ( v, m) ) ;
1190
+ }
1192
1191
ast:: ItemTy ( ref ty, ref ty_params) => {
1193
1192
let qualname = format ! ( "::{}" , self . analysis. ty_cx. map. path_to_string( item. id) ) ;
1194
1193
let value = ty_to_string ( & * * ty) ;
@@ -1295,30 +1294,22 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
1295
1294
ast:: ExprStruct ( ref path, ref fields, ref base) =>
1296
1295
self . process_struct_lit ( ex, path, fields, base) ,
1297
1296
ast:: ExprMethodCall ( _, _, ref args) => self . process_method_call ( ex, args) ,
1298
- ast:: ExprField ( ref sub_ex, ident ) => {
1297
+ ast:: ExprField ( ref sub_ex, _ ) => {
1299
1298
if generated_code ( sub_ex. span ) {
1300
1299
return
1301
1300
}
1302
1301
1303
- self . visit_expr ( & * * sub_ex) ;
1304
- let ty = & ty:: expr_ty_adjusted ( & self . analysis . ty_cx , & * * sub_ex) . sty ;
1305
- match * ty {
1306
- ty:: ty_struct( def_id, _) => {
1307
- let fields = ty:: lookup_struct_fields ( & self . analysis . ty_cx , def_id) ;
1308
- for f in & fields {
1309
- if f. name == ident. node . name {
1310
- let sub_span = self . span . span_for_last_ident ( ex. span ) ;
1311
- self . fmt . ref_str ( recorder:: VarRef ,
1312
- ex. span ,
1313
- sub_span,
1314
- f. id ,
1315
- self . cur_scope ) ;
1316
- break ;
1317
- }
1318
- }
1319
- }
1320
- _ => self . sess . span_bug ( ex. span ,
1321
- & format ! ( "Expected struct type, found {:?}" , ty) ) ,
1302
+ self . visit_expr ( & sub_ex) ;
1303
+
1304
+ let field_data = self . save_ctxt . get_expr_data ( ex) ;
1305
+ if let super :: Data :: VariableRefData ( field_data) = field_data {
1306
+ self . fmt . ref_str ( recorder:: VarRef ,
1307
+ ex. span ,
1308
+ Some ( field_data. span ) ,
1309
+ field_data. ref_id ,
1310
+ field_data. scope ) ;
1311
+ } else {
1312
+ self . sess . span_bug ( ex. span , "expected VariableRefData" ) ;
1322
1313
}
1323
1314
} ,
1324
1315
ast:: ExprTupField ( ref sub_ex, idx) => {
0 commit comments