@@ -199,23 +199,23 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
199
199
self . dumper . compilation_opts ( data) ;
200
200
}
201
201
202
- fn write_sub_paths ( & mut self , path : & ' tcx hir:: Path < ' tcx > ) {
203
- for seg in path . segments {
202
+ fn write_segments ( & mut self , segments : impl IntoIterator < Item = & ' tcx hir:: PathSegment < ' tcx > > ) {
203
+ for seg in segments {
204
204
if let Some ( data) = self . save_ctxt . get_path_segment_data ( seg) {
205
205
self . dumper . dump_ref ( data) ;
206
206
}
207
207
}
208
208
}
209
209
210
+ fn write_sub_paths ( & mut self , path : & ' tcx hir:: Path < ' tcx > ) {
211
+ self . write_segments ( path. segments )
212
+ }
213
+
210
214
// As write_sub_paths, but does not process the last ident in the path (assuming it
211
215
// will be processed elsewhere). See note on write_sub_paths about global.
212
216
fn write_sub_paths_truncated ( & mut self , path : & ' tcx hir:: Path < ' tcx > ) {
213
217
if let [ segments @ .., _] = path. segments {
214
- for seg in segments {
215
- if let Some ( data) = self . save_ctxt . get_path_segment_data ( seg) {
216
- self . dumper . dump_ref ( data) ;
217
- }
218
- }
218
+ self . write_segments ( segments)
219
219
}
220
220
}
221
221
@@ -643,7 +643,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
643
643
self . nest_tables ( map. local_def_id ( item. hir_id ) , |v| {
644
644
v. visit_ty ( & typ) ;
645
645
if let & Some ( ref trait_ref) = trait_ref {
646
- v. process_path ( trait_ref. hir_ref_id , & trait_ref. path ) ;
646
+ v. process_path ( trait_ref. hir_ref_id , & hir :: QPath :: Resolved ( None , & trait_ref. path ) ) ;
647
647
}
648
648
v. process_generic_params ( generics, "" , item. hir_id ) ;
649
649
for impl_item in impl_items {
@@ -746,7 +746,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
746
746
}
747
747
}
748
748
749
- fn dump_path_ref ( & mut self , id : hir:: HirId , path : & hir:: Path < ' tcx > ) {
749
+ fn dump_path_ref ( & mut self , id : hir:: HirId , path : & hir:: QPath < ' tcx > ) {
750
750
let path_data = self . save_ctxt . get_path_data ( id, path) ;
751
751
if let Some ( path_data) = path_data {
752
752
self . dumper . dump_ref ( path_data) ;
@@ -760,14 +760,30 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
760
760
}
761
761
}
762
762
763
- fn process_path ( & mut self , id : hir:: HirId , path : & ' tcx hir:: Path < ' tcx > ) {
764
- if self . span . filter_generated ( path. span ) {
763
+ fn process_path ( & mut self , id : hir:: HirId , path : & hir:: QPath < ' tcx > ) {
764
+ let span = match path {
765
+ hir:: QPath :: Resolved ( _, path) => path. span ,
766
+ hir:: QPath :: TypeRelative ( _, segment) => segment. ident . span ,
767
+ } ;
768
+ if self . span . filter_generated ( span) {
765
769
return ;
766
770
}
767
771
self . dump_path_ref ( id, path) ;
768
772
769
773
// Type arguments
770
- for seg in path. segments {
774
+ let segments = match path {
775
+ hir:: QPath :: Resolved ( ty, path) => {
776
+ if let Some ( ty) = ty {
777
+ self . visit_ty ( ty) ;
778
+ }
779
+ path. segments
780
+ }
781
+ hir:: QPath :: TypeRelative ( ty, segment) => {
782
+ self . visit_ty ( ty) ;
783
+ std:: slice:: from_ref ( * segment)
784
+ }
785
+ } ;
786
+ for seg in segments {
771
787
if let Some ( ref generic_args) = seg. args {
772
788
for arg in generic_args. args {
773
789
if let hir:: GenericArg :: Type ( ref ty) = arg {
@@ -777,7 +793,9 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
777
793
}
778
794
}
779
795
780
- self . write_sub_paths_truncated ( path) ;
796
+ if let hir:: QPath :: Resolved ( _, path) = path {
797
+ self . write_sub_paths_truncated ( path) ;
798
+ }
781
799
}
782
800
783
801
fn process_struct_lit (
@@ -931,9 +949,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
931
949
}
932
950
933
951
for ( id, ref path) in collector. collected_paths {
934
- if let hir:: QPath :: Resolved ( _, path) = path {
935
- self . process_path ( id, path) ;
936
- }
952
+ self . process_path ( id, path) ;
937
953
}
938
954
}
939
955
@@ -1135,7 +1151,10 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
1135
1151
fn process_bounds ( & mut self , bounds : hir:: GenericBounds < ' tcx > ) {
1136
1152
for bound in bounds {
1137
1153
if let hir:: GenericBound :: Trait ( ref trait_ref, _) = * bound {
1138
- self . process_path ( trait_ref. trait_ref . hir_ref_id , & trait_ref. trait_ref . path )
1154
+ self . process_path (
1155
+ trait_ref. trait_ref . hir_ref_id ,
1156
+ & hir:: QPath :: Resolved ( None , & trait_ref. trait_ref . path ) ,
1157
+ )
1139
1158
}
1140
1159
}
1141
1160
}
@@ -1330,13 +1349,16 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
1330
1349
fn visit_ty ( & mut self , t : & ' tcx hir:: Ty < ' tcx > ) {
1331
1350
self . process_macro_use ( t. span ) ;
1332
1351
match t. kind {
1333
- hir:: TyKind :: Path ( hir :: QPath :: Resolved ( _ , path) ) => {
1352
+ hir:: TyKind :: Path ( ref path) => {
1334
1353
if generated_code ( t. span ) {
1335
1354
return ;
1336
1355
}
1337
1356
1338
1357
if let Some ( id) = self . lookup_def_id ( t. hir_id ) {
1339
- let sub_span = path. segments . last ( ) . unwrap ( ) . ident . span ;
1358
+ let sub_span = match path {
1359
+ hir:: QPath :: Resolved ( _, path) => path. segments . last ( ) . unwrap ( ) . ident . span ,
1360
+ hir:: QPath :: TypeRelative ( _, segment) => segment. ident . span ,
1361
+ } ;
1340
1362
let span = self . span_from_span ( sub_span) ;
1341
1363
self . dumper . dump_ref ( Ref {
1342
1364
kind : RefKind :: Type ,
@@ -1345,8 +1367,10 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
1345
1367
} ) ;
1346
1368
}
1347
1369
1348
- self . write_sub_paths_truncated ( path) ;
1349
- intravisit:: walk_path ( self , path) ;
1370
+ if let hir:: QPath :: Resolved ( _, path) = path {
1371
+ self . write_sub_paths_truncated ( path) ;
1372
+ }
1373
+ intravisit:: walk_qpath ( self , path, t. hir_id , t. span ) ;
1350
1374
}
1351
1375
hir:: TyKind :: Array ( ref ty, ref anon_const) => {
1352
1376
self . visit_ty ( ty) ;
@@ -1355,6 +1379,10 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
1355
1379
v. visit_expr ( & map. body ( anon_const. body ) . value )
1356
1380
} ) ;
1357
1381
}
1382
+ hir:: TyKind :: Def ( item_id, _) => {
1383
+ let item = self . tcx . hir ( ) . item ( item_id. id ) ;
1384
+ self . nest_tables ( self . tcx . hir ( ) . local_def_id ( item_id. id ) , |v| v. visit_item ( item) ) ;
1385
+ }
1358
1386
_ => intravisit:: walk_ty ( self , t) ,
1359
1387
}
1360
1388
}
@@ -1432,8 +1460,8 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
1432
1460
self . visit_expr ( & arm. body ) ;
1433
1461
}
1434
1462
1435
- fn visit_path ( & mut self , p : & ' tcx hir:: Path < ' tcx > , id : hir:: HirId ) {
1436
- self . process_path ( id, p ) ;
1463
+ fn visit_qpath ( & mut self , path : & ' tcx hir:: QPath < ' tcx > , id : hir:: HirId , _ : Span ) {
1464
+ self . process_path ( id, path ) ;
1437
1465
}
1438
1466
1439
1467
fn visit_stmt ( & mut self , s : & ' tcx hir:: Stmt < ' tcx > ) {
0 commit comments