@@ -36,15 +36,15 @@ use rustc::ty::{self, TyCtxt, ImplOrTraitItem, ImplOrTraitItemContainer};
3636use std:: collections:: HashSet ;
3737use std:: hash:: * ;
3838
39- use syntax:: ast:: { self , NodeId , PatKind } ;
39+ use syntax:: ast:: { self , NodeId , PatKind , Attribute } ;
4040use syntax:: parse:: token:: { self , keywords} ;
4141use syntax:: visit:: { self , Visitor } ;
4242use syntax:: print:: pprust:: { path_to_string, ty_to_string, bounds_to_string, generics_to_string} ;
4343use syntax:: ptr:: P ;
4444use syntax:: codemap:: Spanned ;
4545use syntax_pos:: * ;
4646
47- use super :: { escape, generated_code, SaveContext , PathCollector } ;
47+ use super :: { escape, generated_code, SaveContext , PathCollector , docs_for_attrs } ;
4848use super :: data:: * ;
4949use super :: dump:: Dump ;
5050use super :: external_data:: Lower ;
@@ -368,6 +368,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
368368 scope : 0 ,
369369 parent : None ,
370370 visibility : Visibility :: Inherited ,
371+ docs : String :: new ( ) ,
371372 } . lower ( self . tcx ) ) ;
372373 }
373374 }
@@ -380,6 +381,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
380381 id : ast:: NodeId ,
381382 name : ast:: Name ,
382383 vis : Visibility ,
384+ attrs : & [ Attribute ] ,
383385 span : Span ) {
384386 debug ! ( "process_method: {}:{}" , id, name) ;
385387
@@ -421,6 +423,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
421423 value : sig_str,
422424 decl_id : decl_id,
423425 visibility : vis,
426+ docs : docs_for_attrs ( attrs) ,
424427 } . lower ( self . tcx ) ) ;
425428 }
426429
@@ -491,6 +494,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
491494 value : String :: new ( ) ,
492495 visibility : Visibility :: Inherited ,
493496 parent : None ,
497+ docs : String :: new ( ) ,
494498 } . lower ( self . tcx ) ) ;
495499 }
496500 }
@@ -541,7 +545,8 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
541545 typ : & ast:: Ty ,
542546 expr : & ast:: Expr ,
543547 parent_id : NodeId ,
544- vis : Visibility ) {
548+ vis : Visibility ,
549+ attrs : & [ Attribute ] ) {
545550 let qualname = format ! ( "::{}" , self . tcx. node_path_str( id) ) ;
546551
547552 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> {
558563 scope : self . cur_scope ,
559564 parent : Some ( parent_id) ,
560565 visibility : vis,
566+ docs : docs_for_attrs ( attrs) ,
561567 } . lower ( self . tcx ) ) ;
562568 }
563569
@@ -600,6 +606,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
600606 value : val,
601607 fields : fields,
602608 visibility : From :: from ( & item. vis ) ,
609+ docs : docs_for_attrs ( & item. attrs ) ,
603610 } . lower ( self . tcx ) ) ;
604611 }
605612
@@ -653,6 +660,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
653660 value : val,
654661 scope : enum_data. scope ,
655662 parent : Some ( item. id ) ,
663+ docs : docs_for_attrs ( & variant. node . attrs ) ,
656664 } . lower ( self . tcx ) ) ;
657665 }
658666 }
@@ -677,6 +685,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
677685 value : val,
678686 scope : enum_data. scope ,
679687 parent : Some ( item. id ) ,
688+ docs : docs_for_attrs ( & variant. node . attrs ) ,
680689 } . lower ( self . tcx ) ) ;
681690 }
682691 }
@@ -759,6 +768,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
759768 value : val,
760769 items : methods. iter ( ) . map ( |i| i. id ) . collect ( ) ,
761770 visibility : From :: from ( & item. vis ) ,
771+ docs : docs_for_attrs ( & item. attrs ) ,
762772 } . lower ( self . tcx ) ) ;
763773 }
764774
@@ -1015,6 +1025,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
10151025 scope : 0 ,
10161026 parent : None ,
10171027 visibility : Visibility :: Inherited ,
1028+ docs : String :: new ( ) ,
10181029 } . lower ( self . tcx ) ) ;
10191030 }
10201031 }
@@ -1044,7 +1055,9 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
10441055 self . dumper . macro_data ( MacroData {
10451056 span : sub_span,
10461057 name : data. name . clone ( ) ,
1047- qualname : qualname. clone ( )
1058+ qualname : qualname. clone ( ) ,
1059+ // FIXME where do macro docs come from?
1060+ docs : String :: new ( ) ,
10481061 } . lower ( self . tcx ) ) ;
10491062 }
10501063 }
@@ -1057,7 +1070,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
10571070 qualname : qualname,
10581071 scope : data. scope ,
10591072 callee_span : data. callee_span ,
1060- imported : data. imported
1073+ imported : data. imported ,
10611074 } . lower ( self . tcx ) ) ;
10621075 }
10631076 }
@@ -1073,14 +1086,16 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
10731086 & ty,
10741087 & expr,
10751088 trait_id,
1076- Visibility :: Public ) ;
1089+ Visibility :: Public ,
1090+ & trait_item. attrs ) ;
10771091 }
10781092 ast:: TraitItemKind :: Method ( ref sig, ref body) => {
10791093 self . process_method ( sig,
10801094 body. as_ref ( ) . map ( |x| & * * x) ,
10811095 trait_item. id ,
10821096 trait_item. ident . name ,
10831097 Visibility :: Public ,
1098+ & trait_item. attrs ,
10841099 trait_item. span ) ;
10851100 }
10861101 ast:: TraitItemKind :: Const ( _, None ) |
@@ -1099,14 +1114,16 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
10991114 & ty,
11001115 & expr,
11011116 impl_id,
1102- From :: from ( & impl_item. vis ) ) ;
1117+ From :: from ( & impl_item. vis ) ,
1118+ & impl_item. attrs ) ;
11031119 }
11041120 ast:: ImplItemKind :: Method ( ref sig, ref body) => {
11051121 self . process_method ( sig,
11061122 Some ( body) ,
11071123 impl_item. id ,
11081124 impl_item. ident . name ,
11091125 From :: from ( & impl_item. vis ) ,
1126+ & impl_item. attrs ,
11101127 impl_item. span ) ;
11111128 }
11121129 ast:: ImplItemKind :: Type ( _) |
@@ -1248,6 +1265,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor for DumpVisitor<'l, 'tcx, 'll, D>
12481265 value : value,
12491266 visibility : From :: from ( & item. vis ) ,
12501267 parent : None ,
1268+ docs : docs_for_attrs ( & item. attrs ) ,
12511269 } . lower ( self . tcx ) ) ;
12521270 }
12531271
@@ -1417,11 +1435,15 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor for DumpVisitor<'l, 'tcx, 'll, D>
14171435 for & ( id, ref p, immut, ref_kind) in & collector. collected_paths {
14181436 match self . tcx . expect_def ( id) {
14191437 Def :: Local ( _, id) => {
1420- let value = if immut == ast:: Mutability :: Immutable {
1438+ let mut value = if immut == ast:: Mutability :: Immutable {
14211439 self . span . snippet ( p. span ) . to_string ( )
14221440 } else {
14231441 "<mutable>" . to_string ( )
14241442 } ;
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) ;
14251447
14261448 assert ! ( p. segments. len( ) == 1 ,
14271449 "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>
14331455 name : path_to_string ( p) ,
14341456 qualname : format ! ( "{}${}" , path_to_string( p) , id) ,
14351457 value : value,
1436- type_value : String :: new ( ) ,
1458+ type_value : typ ,
14371459 scope : 0 ,
14381460 parent : None ,
14391461 visibility : Visibility :: Inherited ,
1462+ docs : String :: new ( ) ,
14401463 } . lower ( self . tcx ) ) ;
14411464 }
14421465 }
0 commit comments