@@ -365,6 +365,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
365365 type_value : typ,
366366 value : String :: new ( ) ,
367367 scope : 0 ,
368+ parent : None ,
368369 visibility : Visibility :: Inherited ,
369370 } . lower ( self . tcx ) ) ;
370371 }
@@ -488,6 +489,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
488489 qualname : qualname,
489490 value : String :: new ( ) ,
490491 visibility : Visibility :: Inherited ,
492+ parent : None ,
491493 } . lower ( self . tcx ) ) ;
492494 }
493495 }
@@ -531,13 +533,14 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
531533 self . visit_expr ( expr) ;
532534 }
533535
534- fn process_const ( & mut self ,
535- id : ast:: NodeId ,
536- name : ast:: Name ,
537- span : Span ,
538- typ : & ast:: Ty ,
539- expr : & ast:: Expr ,
540- vis : Visibility ) {
536+ fn process_assoc_const ( & mut self ,
537+ id : ast:: NodeId ,
538+ name : ast:: Name ,
539+ span : Span ,
540+ typ : & ast:: Ty ,
541+ expr : & ast:: Expr ,
542+ parent_id : NodeId ,
543+ vis : Visibility ) {
541544 let qualname = format ! ( "::{}" , self . tcx. node_path_str( id) ) ;
542545
543546 let sub_span = self . span . sub_span_after_keyword ( span, keywords:: Const ) ;
@@ -552,6 +555,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
552555 value : self . span . snippet ( expr. span ) ,
553556 type_value : ty_to_string ( & typ) ,
554557 scope : self . cur_scope ,
558+ parent : Some ( parent_id) ,
555559 visibility : vis,
556560 } . lower ( self . tcx ) ) ;
557561 }
@@ -646,7 +650,8 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
646650 qualname : qualname,
647651 type_value : enum_data. qualname . clone ( ) ,
648652 value : val,
649- scope : enum_data. scope
653+ scope : enum_data. scope ,
654+ parent : Some ( item. id ) ,
650655 } . lower ( self . tcx ) ) ;
651656 }
652657 }
@@ -669,7 +674,8 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
669674 qualname : qualname,
670675 type_value : enum_data. qualname . clone ( ) ,
671676 value : val,
672- scope : enum_data. scope
677+ scope : enum_data. scope ,
678+ parent : Some ( item. id ) ,
673679 } . lower ( self . tcx ) ) ;
674680 }
675681 }
@@ -722,7 +728,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
722728 }
723729 self . process_generic_params ( type_parameters, item. span , "" , item. id ) ;
724730 for impl_item in impl_items {
725- self . visit_impl_item ( impl_item) ;
731+ self . process_impl_item ( impl_item, item . id ) ;
726732 }
727733 }
728734
@@ -792,7 +798,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
792798 // walk generics and methods
793799 self . process_generic_params ( generics, item. span , & qualname, item. id ) ;
794800 for method in methods {
795- self . visit_trait_item ( method)
801+ self . process_trait_item ( method, item . id )
796802 }
797803 }
798804
@@ -998,6 +1004,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
9981004 value : value,
9991005 type_value : typ,
10001006 scope : 0 ,
1007+ parent : None ,
10011008 visibility : Visibility :: Inherited ,
10021009 } . lower ( self . tcx ) ) ;
10031010 }
@@ -1046,6 +1053,57 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
10461053 }
10471054 }
10481055 }
1056+
1057+ fn process_trait_item ( & mut self , trait_item : & ast:: TraitItem , trait_id : NodeId ) {
1058+ self . process_macro_use ( trait_item. span , trait_item. id ) ;
1059+ match trait_item. node {
1060+ ast:: TraitItemKind :: Const ( ref ty, Some ( ref expr) ) => {
1061+ self . process_assoc_const ( trait_item. id ,
1062+ trait_item. ident . name ,
1063+ trait_item. span ,
1064+ & ty,
1065+ & expr,
1066+ trait_id,
1067+ Visibility :: Public ) ;
1068+ }
1069+ ast:: TraitItemKind :: Method ( ref sig, ref body) => {
1070+ self . process_method ( sig,
1071+ body. as_ref ( ) . map ( |x| & * * x) ,
1072+ trait_item. id ,
1073+ trait_item. ident . name ,
1074+ Visibility :: Public ,
1075+ trait_item. span ) ;
1076+ }
1077+ ast:: TraitItemKind :: Const ( _, None ) |
1078+ ast:: TraitItemKind :: Type ( ..) |
1079+ ast:: TraitItemKind :: Macro ( _) => { }
1080+ }
1081+ }
1082+
1083+ fn process_impl_item ( & mut self , impl_item : & ast:: ImplItem , impl_id : NodeId ) {
1084+ self . process_macro_use ( impl_item. span , impl_item. id ) ;
1085+ match impl_item. node {
1086+ ast:: ImplItemKind :: Const ( ref ty, ref expr) => {
1087+ self . process_assoc_const ( impl_item. id ,
1088+ impl_item. ident . name ,
1089+ impl_item. span ,
1090+ & ty,
1091+ & expr,
1092+ impl_id,
1093+ From :: from ( & impl_item. vis ) ) ;
1094+ }
1095+ ast:: ImplItemKind :: Method ( ref sig, ref body) => {
1096+ self . process_method ( sig,
1097+ Some ( body) ,
1098+ impl_item. id ,
1099+ impl_item. ident . name ,
1100+ From :: from ( & impl_item. vis ) ,
1101+ impl_item. span ) ;
1102+ }
1103+ ast:: ImplItemKind :: Type ( _) |
1104+ ast:: ImplItemKind :: Macro ( _) => { }
1105+ }
1106+ }
10491107}
10501108
10511109impl < ' l , ' tcx : ' l , ' ll , D : Dump +' ll > Visitor for DumpVisitor < ' l , ' tcx , ' ll , D > {
@@ -1180,6 +1238,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor for DumpVisitor<'l, 'tcx, 'll, D>
11801238 qualname : qualname. clone ( ) ,
11811239 value : value,
11821240 visibility : From :: from ( & item. vis ) ,
1241+ parent : None ,
11831242 } . lower ( self . tcx ) ) ;
11841243 }
11851244
@@ -1204,55 +1263,6 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor for DumpVisitor<'l, 'tcx, 'll, D>
12041263 }
12051264 }
12061265
1207- fn visit_trait_item ( & mut self , trait_item : & ast:: TraitItem ) {
1208- self . process_macro_use ( trait_item. span , trait_item. id ) ;
1209- match trait_item. node {
1210- ast:: TraitItemKind :: Const ( ref ty, Some ( ref expr) ) => {
1211- self . process_const ( trait_item. id ,
1212- trait_item. ident . name ,
1213- trait_item. span ,
1214- & ty,
1215- & expr,
1216- Visibility :: Public ) ;
1217- }
1218- ast:: TraitItemKind :: Method ( ref sig, ref body) => {
1219- self . process_method ( sig,
1220- body. as_ref ( ) . map ( |x| & * * x) ,
1221- trait_item. id ,
1222- trait_item. ident . name ,
1223- Visibility :: Public ,
1224- trait_item. span ) ;
1225- }
1226- ast:: TraitItemKind :: Const ( _, None ) |
1227- ast:: TraitItemKind :: Type ( ..) |
1228- ast:: TraitItemKind :: Macro ( _) => { }
1229- }
1230- }
1231-
1232- fn visit_impl_item ( & mut self , impl_item : & ast:: ImplItem ) {
1233- self . process_macro_use ( impl_item. span , impl_item. id ) ;
1234- match impl_item. node {
1235- ast:: ImplItemKind :: Const ( ref ty, ref expr) => {
1236- self . process_const ( impl_item. id ,
1237- impl_item. ident . name ,
1238- impl_item. span ,
1239- & ty,
1240- & expr,
1241- From :: from ( & impl_item. vis ) ) ;
1242- }
1243- ast:: ImplItemKind :: Method ( ref sig, ref body) => {
1244- self . process_method ( sig,
1245- Some ( body) ,
1246- impl_item. id ,
1247- impl_item. ident . name ,
1248- From :: from ( & impl_item. vis ) ,
1249- impl_item. span ) ;
1250- }
1251- ast:: ImplItemKind :: Type ( _) |
1252- ast:: ImplItemKind :: Macro ( _) => { }
1253- }
1254- }
1255-
12561266 fn visit_ty ( & mut self , t : & ast:: Ty ) {
12571267 self . process_macro_use ( t. span , t. id ) ;
12581268 match t. node {
@@ -1416,6 +1426,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor for DumpVisitor<'l, 'tcx, 'll, D>
14161426 value : value,
14171427 type_value : String :: new ( ) ,
14181428 scope : 0 ,
1429+ parent : None ,
14191430 visibility : Visibility :: Inherited ,
14201431 } . lower ( self . tcx ) ) ;
14211432 }
0 commit comments