@@ -365,6 +365,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
365
365
type_value : typ,
366
366
value : String :: new ( ) ,
367
367
scope : 0 ,
368
+ parent : None ,
368
369
visibility : Visibility :: Inherited ,
369
370
} . lower ( self . tcx ) ) ;
370
371
}
@@ -488,6 +489,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
488
489
qualname : qualname,
489
490
value : String :: new ( ) ,
490
491
visibility : Visibility :: Inherited ,
492
+ parent : None ,
491
493
} . lower ( self . tcx ) ) ;
492
494
}
493
495
}
@@ -531,13 +533,14 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
531
533
self . visit_expr ( expr) ;
532
534
}
533
535
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 ) {
541
544
let qualname = format ! ( "::{}" , self . tcx. node_path_str( id) ) ;
542
545
543
546
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> {
552
555
value : self . span . snippet ( expr. span ) ,
553
556
type_value : ty_to_string ( & typ) ,
554
557
scope : self . cur_scope ,
558
+ parent : Some ( parent_id) ,
555
559
visibility : vis,
556
560
} . lower ( self . tcx ) ) ;
557
561
}
@@ -646,7 +650,8 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
646
650
qualname : qualname,
647
651
type_value : enum_data. qualname . clone ( ) ,
648
652
value : val,
649
- scope : enum_data. scope
653
+ scope : enum_data. scope ,
654
+ parent : Some ( item. id ) ,
650
655
} . lower ( self . tcx ) ) ;
651
656
}
652
657
}
@@ -669,7 +674,8 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
669
674
qualname : qualname,
670
675
type_value : enum_data. qualname . clone ( ) ,
671
676
value : val,
672
- scope : enum_data. scope
677
+ scope : enum_data. scope ,
678
+ parent : Some ( item. id ) ,
673
679
} . lower ( self . tcx ) ) ;
674
680
}
675
681
}
@@ -722,7 +728,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
722
728
}
723
729
self . process_generic_params ( type_parameters, item. span , "" , item. id ) ;
724
730
for impl_item in impl_items {
725
- self . visit_impl_item ( impl_item) ;
731
+ self . process_impl_item ( impl_item, item . id ) ;
726
732
}
727
733
}
728
734
@@ -792,7 +798,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
792
798
// walk generics and methods
793
799
self . process_generic_params ( generics, item. span , & qualname, item. id ) ;
794
800
for method in methods {
795
- self . visit_trait_item ( method)
801
+ self . process_trait_item ( method, item . id )
796
802
}
797
803
}
798
804
@@ -998,6 +1004,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
998
1004
value : value,
999
1005
type_value : typ,
1000
1006
scope : 0 ,
1007
+ parent : None ,
1001
1008
visibility : Visibility :: Inherited ,
1002
1009
} . lower ( self . tcx ) ) ;
1003
1010
}
@@ -1046,6 +1053,57 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
1046
1053
}
1047
1054
}
1048
1055
}
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
+ }
1049
1107
}
1050
1108
1051
1109
impl < ' 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>
1180
1238
qualname : qualname. clone ( ) ,
1181
1239
value : value,
1182
1240
visibility : From :: from ( & item. vis ) ,
1241
+ parent : None ,
1183
1242
} . lower ( self . tcx ) ) ;
1184
1243
}
1185
1244
@@ -1204,55 +1263,6 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor for DumpVisitor<'l, 'tcx, 'll, D>
1204
1263
}
1205
1264
}
1206
1265
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
-
1256
1266
fn visit_ty ( & mut self , t : & ast:: Ty ) {
1257
1267
self . process_macro_use ( t. span , t. id ) ;
1258
1268
match t. node {
@@ -1416,6 +1426,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor for DumpVisitor<'l, 'tcx, 'll, D>
1416
1426
value : value,
1417
1427
type_value : String :: new ( ) ,
1418
1428
scope : 0 ,
1429
+ parent : None ,
1419
1430
visibility : Visibility :: Inherited ,
1420
1431
} . lower ( self . tcx ) ) ;
1421
1432
}
0 commit comments