@@ -89,7 +89,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
89
89
sess : sess,
90
90
err_count : Cell :: new ( 0 )
91
91
} ) ,
92
- cur_scope : 0
92
+ cur_scope : 0
93
93
}
94
94
}
95
95
@@ -108,7 +108,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
108
108
109
109
// Dump info about all the external crates referenced from this crate.
110
110
for c in & self . save_ctxt . get_external_crates ( ) {
111
- self . fmt . external_crate_str ( krate. span , & c. name , c. number ) ;
111
+ self . fmt . external_crate_str ( krate. span , & c. name , c. number ) ;
112
112
}
113
113
self . fmt . recorder . record ( "end_external_crates\n " ) ;
114
114
}
@@ -496,58 +496,52 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
496
496
decl : & ast:: FnDecl ,
497
497
ty_params : & ast:: Generics ,
498
498
body : & ast:: Block ) {
499
- let qualname = format ! ( "::{}" , self . analysis. ty_cx. map. path_to_string( item. id) ) ;
499
+ let fn_data = self . save_ctxt . get_item_data ( item) ;
500
+ if let super :: Data :: FunctionData ( fn_data) = fn_data {
501
+ self . fmt . fn_str ( item. span ,
502
+ Some ( fn_data. span ) ,
503
+ fn_data. id ,
504
+ & fn_data. qualname ,
505
+ fn_data. scope ) ;
500
506
501
- let sub_span = self . span . sub_span_after_keyword ( item. span , keywords:: Fn ) ;
502
- self . fmt . fn_str ( item. span ,
503
- sub_span,
504
- item. id ,
505
- & qualname[ ..] ,
506
- self . cur_scope ) ;
507
507
508
- self . process_formals ( & decl. inputs , & qualname[ ..] ) ;
508
+ self . process_formals ( & decl. inputs , & fn_data. qualname ) ;
509
+ self . process_generic_params ( ty_params, item. span , & fn_data. qualname , item. id ) ;
510
+ } else {
511
+ unreachable ! ( ) ;
512
+ }
509
513
510
- // walk arg and return types
511
514
for arg in & decl. inputs {
512
- self . visit_ty ( & * arg. ty ) ;
515
+ self . visit_ty ( & arg. ty ) ;
513
516
}
514
517
515
518
if let ast:: Return ( ref ret_ty) = decl. output {
516
- self . visit_ty ( & * * ret_ty) ;
519
+ self . visit_ty ( & ret_ty) ;
517
520
}
518
521
519
- // walk the body
520
- self . nest ( item. id , |v| v. visit_block ( & * body) ) ;
521
-
522
- self . process_generic_params ( ty_params, item. span , & qualname[ ..] , item. id ) ;
522
+ self . nest ( item. id , |v| v. visit_block ( & body) ) ;
523
523
}
524
524
525
- fn process_static ( & mut self ,
526
- item : & ast:: Item ,
527
- typ : & ast:: Ty ,
528
- mt : ast:: Mutability ,
529
- expr : & ast:: Expr )
525
+ fn process_static_or_const_item ( & mut self ,
526
+ item : & ast:: Item ,
527
+ typ : & ast:: Ty ,
528
+ expr : & ast:: Expr )
530
529
{
531
- let qualname = format ! ( "::{}" , self . analysis. ty_cx. map. path_to_string( item. id) ) ;
532
-
533
- // If the variable is immutable, save the initialising expression.
534
- let ( value, keyword) = match mt {
535
- ast:: MutMutable => ( String :: from_str ( "<mutable>" ) , keywords:: Mut ) ,
536
- ast:: MutImmutable => ( self . span . snippet ( expr. span ) , keywords:: Static ) ,
537
- } ;
538
-
539
- let sub_span = self . span . sub_span_after_keyword ( item. span , keyword) ;
540
- self . fmt . static_str ( item. span ,
541
- sub_span,
542
- item. id ,
543
- & get_ident ( item. ident ) ,
544
- & qualname[ ..] ,
545
- & value[ ..] ,
546
- & ty_to_string ( & * typ) ,
547
- self . cur_scope ) ;
530
+ let var_data = self . save_ctxt . get_item_data ( item) ;
531
+ if let super :: Data :: VariableData ( var_data) = var_data {
532
+ self . fmt . static_str ( item. span ,
533
+ Some ( var_data. span ) ,
534
+ var_data. id ,
535
+ & var_data. name ,
536
+ & var_data. qualname ,
537
+ & var_data. value ,
538
+ & var_data. type_value ,
539
+ var_data. scope ) ;
540
+ } else {
541
+ unreachable ! ( ) ;
542
+ }
548
543
549
- // walk type and init value
550
- self . visit_ty ( & * typ) ;
544
+ self . visit_ty ( & typ) ;
551
545
self . visit_expr ( expr) ;
552
546
}
553
547
@@ -562,12 +556,13 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
562
556
563
557
let sub_span = self . span . sub_span_after_keyword ( span,
564
558
keywords:: Const ) ;
559
+
565
560
self . fmt . static_str ( span,
566
561
sub_span,
567
562
id,
568
563
& get_ident ( ( * ident) . clone ( ) ) ,
569
564
& qualname[ ..] ,
570
- "" ,
565
+ & self . span . snippet ( expr . span ) ,
571
566
& ty_to_string ( & * typ) ,
572
567
self . cur_scope ) ;
573
568
@@ -1174,10 +1169,10 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
1174
1169
}
1175
1170
ast:: ItemFn ( ref decl, _, _, ref ty_params, ref body) =>
1176
1171
self . process_fn ( item, & * * decl, ty_params, & * * body) ,
1177
- ast:: ItemStatic ( ref typ, mt , ref expr) =>
1178
- self . process_static ( item, & * * typ, mt , & * * expr) ,
1172
+ ast:: ItemStatic ( ref typ, _ , ref expr) =>
1173
+ self . process_static_or_const_item ( item, typ, expr) ,
1179
1174
ast:: ItemConst ( ref typ, ref expr) =>
1180
- self . process_const ( item. id , & item . ident , item . span , & * typ, & * expr) ,
1175
+ self . process_static_or_const_item ( item, & typ, & expr) ,
1181
1176
ast:: ItemStruct ( ref def, ref ty_params) => self . process_struct ( item, & * * def, ty_params) ,
1182
1177
ast:: ItemEnum ( ref def, ref ty_params) => self . process_enum ( item, def, ty_params) ,
1183
1178
ast:: ItemImpl ( _, _,
@@ -1378,7 +1373,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
1378
1373
} ,
1379
1374
_ => {
1380
1375
visit:: walk_expr ( self , ex)
1381
- } ,
1376
+ }
1382
1377
}
1383
1378
}
1384
1379
@@ -1401,7 +1396,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
1401
1396
// This is to get around borrow checking, because we need mut self to call process_path.
1402
1397
let mut paths_to_process = vec ! [ ] ;
1403
1398
// process collected paths
1404
- for & ( id, ref p, ref immut, ref_kind) in & collector. collected_paths {
1399
+ for & ( id, ref p, immut, ref_kind) in & collector. collected_paths {
1405
1400
let def_map = self . analysis . ty_cx . def_map . borrow ( ) ;
1406
1401
if !def_map. contains_key ( & id) {
1407
1402
self . sess . span_bug ( p. span ,
@@ -1411,7 +1406,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
1411
1406
let def = def_map. get ( & id) . unwrap ( ) . full_def ( ) ;
1412
1407
match def {
1413
1408
def:: DefLocal ( id) => {
1414
- let value = if * immut {
1409
+ let value = if immut == ast :: MutImmutable {
1415
1410
self . span . snippet ( p. span ) . to_string ( )
1416
1411
} else {
1417
1412
"<mutable>" . to_string ( )
@@ -1464,8 +1459,12 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
1464
1459
1465
1460
let value = self . span . snippet ( l. span ) ;
1466
1461
1467
- for & ( id, ref p, ref immut, _) in & collector. collected_paths {
1468
- let value = if * immut { value. to_string ( ) } else { "<mutable>" . to_string ( ) } ;
1462
+ for & ( id, ref p, immut, _) in & collector. collected_paths {
1463
+ let value = if immut == ast:: MutImmutable {
1464
+ value. to_string ( )
1465
+ } else {
1466
+ "<mutable>" . to_string ( )
1467
+ } ;
1469
1468
let types = self . analysis . ty_cx . node_types ( ) ;
1470
1469
let typ = ppaux:: ty_to_string ( & self . analysis . ty_cx , * types. get ( & id) . unwrap ( ) ) ;
1471
1470
// Get the span only for the name of the variable (I hope the path
0 commit comments