@@ -318,25 +318,24 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
318
318
let mut collector = PathCollector :: new ( ) ;
319
319
collector. visit_pat ( & arg. pat ) ;
320
320
let span_utils = self . span . clone ( ) ;
321
- for & ( id, ref p, ..) in & collector. collected_paths {
321
+
322
+ for ( id, i, sp, ..) in collector. collected_idents {
322
323
let hir_id = self . tcx . hir . node_to_hir_id ( id) ;
323
324
let typ = match self . save_ctxt . tables . node_id_to_type_opt ( hir_id) {
324
325
Some ( s) => s. to_string ( ) ,
325
326
None => continue ,
326
327
} ;
327
- // get the span only for the name of the variable (I hope the path is only ever a
328
- // variable name, but who knows?)
329
- let sub_span = span_utils. span_for_last_ident ( p. span ) ;
330
- if !self . span . filter_generated ( sub_span, p. span ) {
328
+ let sub_span = span_utils. span_for_last_ident ( sp) ;
329
+ if !self . span . filter_generated ( sub_span, sp) {
331
330
let id = :: id_from_node_id ( id, & self . save_ctxt ) ;
332
331
let span = self . span_from_span ( sub_span. expect ( "No span found for variable" ) ) ;
333
332
334
333
self . dumper . dump_def ( false , Def {
335
334
kind : DefKind :: Local ,
336
335
id,
337
336
span,
338
- name : path_to_string ( p ) ,
339
- qualname : format ! ( "{}::{}" , qualname, path_to_string ( p ) ) ,
337
+ name : i . to_string ( ) ,
338
+ qualname : format ! ( "{}::{}" , qualname, i . to_string ( ) ) ,
340
339
value : typ,
341
340
parent : None ,
342
341
children : vec ! [ ] ,
@@ -391,14 +390,6 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
391
390
}
392
391
}
393
392
394
- fn process_trait_ref ( & mut self , trait_ref : & ' l ast:: TraitRef ) {
395
- let trait_ref_data = self . save_ctxt . get_trait_ref_data ( trait_ref) ;
396
- if let Some ( trait_ref_data) = trait_ref_data {
397
- self . dumper . dump_ref ( trait_ref_data) ;
398
- }
399
- self . process_path ( trait_ref. ref_id , & trait_ref. path ) ;
400
- }
401
-
402
393
fn process_struct_field_def ( & mut self , field : & ast:: StructField , parent_id : NodeId ) {
403
394
let field_data = self . save_ctxt . get_field_data ( field, parent_id) ;
404
395
if let Some ( field_data) = field_data {
@@ -783,7 +774,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
783
774
}
784
775
}
785
776
786
- fn process_path ( & mut self , id : NodeId , path : & ast:: Path ) {
777
+ fn process_path ( & mut self , id : NodeId , path : & ' l ast:: Path ) {
787
778
let path_data = self . save_ctxt . get_path_data ( id, path) ;
788
779
if generated_code ( path. span ) && path_data. is_none ( ) {
789
780
return ;
@@ -798,6 +789,27 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
798
789
799
790
self . dumper . dump_ref ( path_data) ;
800
791
792
+ // Type parameters
793
+ for seg in & path. segments {
794
+ if let Some ( ref params) = seg. parameters {
795
+ match * * params {
796
+ ast:: PathParameters :: AngleBracketed ( ref data) => {
797
+ for t in & data. types {
798
+ self . visit_ty ( t) ;
799
+ }
800
+ }
801
+ ast:: PathParameters :: Parenthesized ( ref data) => {
802
+ for t in & data. inputs {
803
+ self . visit_ty ( t) ;
804
+ }
805
+ if let Some ( ref t) = data. output {
806
+ self . visit_ty ( t) ;
807
+ }
808
+ }
809
+ }
810
+ }
811
+ }
812
+
801
813
// Modules or types in the path prefix.
802
814
match self . save_ctxt . get_path_def ( id) {
803
815
HirDef :: Method ( did) => {
@@ -904,7 +916,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
904
916
collector. visit_pat ( & p) ;
905
917
self . visit_pat ( & p) ;
906
918
907
- for & ( id, ref p , immut) in & collector. collected_paths {
919
+ for ( id, i , sp , immut) in collector. collected_idents {
908
920
let mut value = match immut {
909
921
ast:: Mutability :: Immutable => value. to_string ( ) ,
910
922
_ => String :: new ( ) ,
@@ -924,18 +936,18 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
924
936
925
937
// Get the span only for the name of the variable (I hope the path
926
938
// is only ever a variable name, but who knows?).
927
- let sub_span = self . span . span_for_last_ident ( p . span ) ;
939
+ let sub_span = self . span . span_for_last_ident ( sp ) ;
928
940
// Rust uses the id of the pattern for var lookups, so we'll use it too.
929
- if !self . span . filter_generated ( sub_span, p . span ) {
930
- let qualname = format ! ( "{}${}" , path_to_string ( p ) , id) ;
941
+ if !self . span . filter_generated ( sub_span, sp ) {
942
+ let qualname = format ! ( "{}${}" , i . to_string ( ) , id) ;
931
943
let id = :: id_from_node_id ( id, & self . save_ctxt ) ;
932
944
let span = self . span_from_span ( sub_span. expect ( "No span found for variable" ) ) ;
933
945
934
946
self . dumper . dump_def ( false , Def {
935
947
kind : DefKind :: Local ,
936
948
id,
937
949
span,
938
- name : path_to_string ( p ) ,
950
+ name : i . to_string ( ) ,
939
951
qualname,
940
952
value : typ,
941
953
parent : None ,
@@ -1263,7 +1275,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
1263
1275
for param in generics. ty_params . iter ( ) {
1264
1276
for bound in param. bounds . iter ( ) {
1265
1277
if let ast:: TraitTyParamBound ( ref trait_ref, _) = * bound {
1266
- self . process_trait_ref ( & trait_ref. trait_ref ) ;
1278
+ self . process_path ( trait_ref . trait_ref . ref_id , & trait_ref. trait_ref . path )
1267
1279
}
1268
1280
}
1269
1281
if let Some ( ref ty) = param. default {
@@ -1430,15 +1442,12 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
1430
1442
self . visit_pat ( & pattern) ;
1431
1443
}
1432
1444
1433
- // This is to get around borrow checking, because we need mut self to call process_path.
1434
- let mut paths_to_process = vec ! [ ] ;
1435
-
1436
1445
// process collected paths
1437
- for & ( id, ref p , immut) in & collector. collected_paths {
1446
+ for ( id, i , sp , immut) in collector. collected_idents {
1438
1447
match self . save_ctxt . get_path_def ( id) {
1439
1448
HirDef :: Local ( id) => {
1440
1449
let mut value = if immut == ast:: Mutability :: Immutable {
1441
- self . span . snippet ( p . span ) . to_string ( )
1450
+ self . span . snippet ( sp ) . to_string ( )
1442
1451
} else {
1443
1452
"<mutable>" . to_string ( )
1444
1453
} ;
@@ -1451,18 +1460,16 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
1451
1460
value. push_str ( ": " ) ;
1452
1461
value. push_str ( & typ) ;
1453
1462
1454
- assert ! ( p. segments. len( ) == 1 ,
1455
- "qualified path for local variable def in arm" ) ;
1456
- if !self . span . filter_generated ( Some ( p. span ) , p. span ) {
1457
- let qualname = format ! ( "{}${}" , path_to_string( p) , id) ;
1463
+ if !self . span . filter_generated ( Some ( sp) , sp) {
1464
+ let qualname = format ! ( "{}${}" , i. to_string( ) , id) ;
1458
1465
let id = :: id_from_node_id ( id, & self . save_ctxt ) ;
1459
- let span = self . span_from_span ( p . span ) ;
1466
+ let span = self . span_from_span ( sp ) ;
1460
1467
1461
1468
self . dumper . dump_def ( false , Def {
1462
1469
kind : DefKind :: Local ,
1463
1470
id,
1464
1471
span,
1465
- name : path_to_string ( p ) ,
1472
+ name : i . to_string ( ) ,
1466
1473
qualname,
1467
1474
value : typ,
1468
1475
parent : None ,
@@ -1474,19 +1481,12 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
1474
1481
} ) ;
1475
1482
}
1476
1483
}
1477
- HirDef :: StructCtor ( ..) | HirDef :: VariantCtor ( ..) |
1478
- HirDef :: Const ( ..) | HirDef :: AssociatedConst ( ..) |
1479
- HirDef :: Struct ( ..) | HirDef :: Variant ( ..) |
1480
- HirDef :: TyAlias ( ..) | HirDef :: AssociatedTy ( ..) |
1481
- HirDef :: SelfTy ( ..) => {
1482
- paths_to_process. push ( ( id, p. clone ( ) ) )
1483
- }
1484
- def => error ! ( "unexpected definition kind when processing collected paths: {:?}" ,
1484
+ def => error ! ( "unexpected definition kind when processing collected idents: {:?}" ,
1485
1485
def) ,
1486
1486
}
1487
1487
}
1488
1488
1489
- for & ( id, ref path) in & paths_to_process {
1489
+ for ( id, ref path) in collector . collected_paths {
1490
1490
self . process_path ( id, path) ;
1491
1491
}
1492
1492
walk_list ! ( self , visit_expr, & arm. guard) ;
0 commit comments