@@ -36,15 +36,15 @@ use rustc::ty::{self, TyCtxt, ImplOrTraitItem, ImplOrTraitItemContainer};
36
36
use std:: collections:: HashSet ;
37
37
use std:: hash:: * ;
38
38
39
- use syntax:: ast:: { self , NodeId , PatKind } ;
39
+ use syntax:: ast:: { self , NodeId , PatKind , Attribute } ;
40
40
use syntax:: parse:: token:: { self , keywords} ;
41
41
use syntax:: visit:: { self , Visitor } ;
42
42
use syntax:: print:: pprust:: { path_to_string, ty_to_string, bounds_to_string, generics_to_string} ;
43
43
use syntax:: ptr:: P ;
44
44
use syntax:: codemap:: Spanned ;
45
45
use syntax_pos:: * ;
46
46
47
- use super :: { escape, generated_code, SaveContext , PathCollector } ;
47
+ use super :: { escape, generated_code, SaveContext , PathCollector , docs_for_attrs } ;
48
48
use super :: data:: * ;
49
49
use super :: dump:: Dump ;
50
50
use super :: external_data:: Lower ;
@@ -368,6 +368,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
368
368
scope : 0 ,
369
369
parent : None ,
370
370
visibility : Visibility :: Inherited ,
371
+ docs : String :: new ( ) ,
371
372
} . lower ( self . tcx ) ) ;
372
373
}
373
374
}
@@ -380,6 +381,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
380
381
id : ast:: NodeId ,
381
382
name : ast:: Name ,
382
383
vis : Visibility ,
384
+ attrs : & [ Attribute ] ,
383
385
span : Span ) {
384
386
debug ! ( "process_method: {}:{}" , id, name) ;
385
387
@@ -421,6 +423,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
421
423
value : sig_str,
422
424
decl_id : decl_id,
423
425
visibility : vis,
426
+ docs : docs_for_attrs ( attrs) ,
424
427
} . lower ( self . tcx ) ) ;
425
428
}
426
429
@@ -491,6 +494,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
491
494
value : String :: new ( ) ,
492
495
visibility : Visibility :: Inherited ,
493
496
parent : None ,
497
+ docs : String :: new ( ) ,
494
498
} . lower ( self . tcx ) ) ;
495
499
}
496
500
}
@@ -541,7 +545,8 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
541
545
typ : & ast:: Ty ,
542
546
expr : & ast:: Expr ,
543
547
parent_id : NodeId ,
544
- vis : Visibility ) {
548
+ vis : Visibility ,
549
+ attrs : & [ Attribute ] ) {
545
550
let qualname = format ! ( "::{}" , self . tcx. node_path_str( id) ) ;
546
551
547
552
let sub_span = self . span . sub_span_after_keyword ( span, keywords:: Const ) ;
@@ -558,6 +563,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
558
563
scope : self . cur_scope ,
559
564
parent : Some ( parent_id) ,
560
565
visibility : vis,
566
+ docs : docs_for_attrs ( attrs) ,
561
567
} . lower ( self . tcx ) ) ;
562
568
}
563
569
@@ -600,6 +606,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
600
606
value : val,
601
607
fields : fields,
602
608
visibility : From :: from ( & item. vis ) ,
609
+ docs : docs_for_attrs ( & item. attrs ) ,
603
610
} . lower ( self . tcx ) ) ;
604
611
}
605
612
@@ -653,6 +660,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
653
660
value : val,
654
661
scope : enum_data. scope ,
655
662
parent : Some ( item. id ) ,
663
+ docs : docs_for_attrs ( & variant. node . attrs ) ,
656
664
} . lower ( self . tcx ) ) ;
657
665
}
658
666
}
@@ -677,6 +685,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
677
685
value : val,
678
686
scope : enum_data. scope ,
679
687
parent : Some ( item. id ) ,
688
+ docs : docs_for_attrs ( & variant. node . attrs ) ,
680
689
} . lower ( self . tcx ) ) ;
681
690
}
682
691
}
@@ -759,6 +768,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
759
768
value : val,
760
769
items : methods. iter ( ) . map ( |i| i. id ) . collect ( ) ,
761
770
visibility : From :: from ( & item. vis ) ,
771
+ docs : docs_for_attrs ( & item. attrs ) ,
762
772
} . lower ( self . tcx ) ) ;
763
773
}
764
774
@@ -1015,6 +1025,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
1015
1025
scope : 0 ,
1016
1026
parent : None ,
1017
1027
visibility : Visibility :: Inherited ,
1028
+ docs : String :: new ( ) ,
1018
1029
} . lower ( self . tcx ) ) ;
1019
1030
}
1020
1031
}
@@ -1044,7 +1055,9 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
1044
1055
self . dumper . macro_data ( MacroData {
1045
1056
span : sub_span,
1046
1057
name : data. name . clone ( ) ,
1047
- qualname : qualname. clone ( )
1058
+ qualname : qualname. clone ( ) ,
1059
+ // FIXME where do macro docs come from?
1060
+ docs : String :: new ( ) ,
1048
1061
} . lower ( self . tcx ) ) ;
1049
1062
}
1050
1063
}
@@ -1057,7 +1070,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
1057
1070
qualname : qualname,
1058
1071
scope : data. scope ,
1059
1072
callee_span : data. callee_span ,
1060
- imported : data. imported
1073
+ imported : data. imported ,
1061
1074
} . lower ( self . tcx ) ) ;
1062
1075
}
1063
1076
}
@@ -1073,14 +1086,16 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
1073
1086
& ty,
1074
1087
& expr,
1075
1088
trait_id,
1076
- Visibility :: Public ) ;
1089
+ Visibility :: Public ,
1090
+ & trait_item. attrs ) ;
1077
1091
}
1078
1092
ast:: TraitItemKind :: Method ( ref sig, ref body) => {
1079
1093
self . process_method ( sig,
1080
1094
body. as_ref ( ) . map ( |x| & * * x) ,
1081
1095
trait_item. id ,
1082
1096
trait_item. ident . name ,
1083
1097
Visibility :: Public ,
1098
+ & trait_item. attrs ,
1084
1099
trait_item. span ) ;
1085
1100
}
1086
1101
ast:: TraitItemKind :: Const ( _, None ) |
@@ -1099,14 +1114,16 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
1099
1114
& ty,
1100
1115
& expr,
1101
1116
impl_id,
1102
- From :: from ( & impl_item. vis ) ) ;
1117
+ From :: from ( & impl_item. vis ) ,
1118
+ & impl_item. attrs ) ;
1103
1119
}
1104
1120
ast:: ImplItemKind :: Method ( ref sig, ref body) => {
1105
1121
self . process_method ( sig,
1106
1122
Some ( body) ,
1107
1123
impl_item. id ,
1108
1124
impl_item. ident . name ,
1109
1125
From :: from ( & impl_item. vis ) ,
1126
+ & impl_item. attrs ,
1110
1127
impl_item. span ) ;
1111
1128
}
1112
1129
ast:: ImplItemKind :: Type ( _) |
@@ -1248,6 +1265,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor for DumpVisitor<'l, 'tcx, 'll, D>
1248
1265
value : value,
1249
1266
visibility : From :: from ( & item. vis ) ,
1250
1267
parent : None ,
1268
+ docs : docs_for_attrs ( & item. attrs ) ,
1251
1269
} . lower ( self . tcx ) ) ;
1252
1270
}
1253
1271
@@ -1417,11 +1435,15 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor for DumpVisitor<'l, 'tcx, 'll, D>
1417
1435
for & ( id, ref p, immut, ref_kind) in & collector. collected_paths {
1418
1436
match self . tcx . expect_def ( id) {
1419
1437
Def :: Local ( _, id) => {
1420
- let value = if immut == ast:: Mutability :: Immutable {
1438
+ let mut value = if immut == ast:: Mutability :: Immutable {
1421
1439
self . span . snippet ( p. span ) . to_string ( )
1422
1440
} else {
1423
1441
"<mutable>" . to_string ( )
1424
1442
} ;
1443
+ let typ = self . tcx . node_types ( )
1444
+ . get ( & id) . map ( |t| t. to_string ( ) ) . unwrap_or ( String :: new ( ) ) ;
1445
+ value. push_str ( ": " ) ;
1446
+ value. push_str ( & typ) ;
1425
1447
1426
1448
assert ! ( p. segments. len( ) == 1 ,
1427
1449
"qualified path for local variable def in arm" ) ;
@@ -1433,10 +1455,11 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor for DumpVisitor<'l, 'tcx, 'll, D>
1433
1455
name : path_to_string ( p) ,
1434
1456
qualname : format ! ( "{}${}" , path_to_string( p) , id) ,
1435
1457
value : value,
1436
- type_value : String :: new ( ) ,
1458
+ type_value : typ ,
1437
1459
scope : 0 ,
1438
1460
parent : None ,
1439
1461
visibility : Visibility :: Inherited ,
1462
+ docs : String :: new ( ) ,
1440
1463
} . lower ( self . tcx ) ) ;
1441
1464
}
1442
1465
}
0 commit comments