@@ -322,25 +322,24 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
322
322
let mut collector = PathCollector :: new ( ) ;
323
323
collector. visit_pat ( & arg. pat ) ;
324
324
let span_utils = self . span . clone ( ) ;
325
- for & ( id, ref p, ..) in & collector. collected_paths {
325
+
326
+ for ( id, i, sp, ..) in collector. collected_idents {
326
327
let hir_id = self . tcx . hir . node_to_hir_id ( id) ;
327
328
let typ = match self . save_ctxt . tables . node_id_to_type_opt ( hir_id) {
328
329
Some ( s) => s. to_string ( ) ,
329
330
None => continue ,
330
331
} ;
331
- // get the span only for the name of the variable (I hope the path is only ever a
332
- // variable name, but who knows?)
333
- let sub_span = span_utils. span_for_last_ident ( p. span ) ;
334
- if !self . span . filter_generated ( sub_span, p. span ) {
332
+ let sub_span = span_utils. span_for_last_ident ( sp) ;
333
+ if !self . span . filter_generated ( sub_span, sp) {
335
334
let id = :: id_from_node_id ( id, & self . save_ctxt ) ;
336
335
let span = self . span_from_span ( sub_span. expect ( "No span found for variable" ) ) ;
337
336
338
337
self . dumper . dump_def ( false , Def {
339
338
kind : DefKind :: Local ,
340
339
id,
341
340
span,
342
- name : path_to_string ( p ) ,
343
- qualname : format ! ( "{}::{}" , qualname, path_to_string ( p ) ) ,
341
+ name : i . to_string ( ) ,
342
+ qualname : format ! ( "{}::{}" , qualname, i . to_string ( ) ) ,
344
343
value : typ,
345
344
parent : None ,
346
345
children : vec ! [ ] ,
@@ -395,14 +394,6 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
395
394
}
396
395
}
397
396
398
- fn process_trait_ref ( & mut self , trait_ref : & ' l ast:: TraitRef ) {
399
- let trait_ref_data = self . save_ctxt . get_trait_ref_data ( trait_ref) ;
400
- if let Some ( trait_ref_data) = trait_ref_data {
401
- self . dumper . dump_ref ( trait_ref_data) ;
402
- }
403
- self . process_path ( trait_ref. ref_id , & trait_ref. path ) ;
404
- }
405
-
406
397
fn process_struct_field_def ( & mut self , field : & ast:: StructField , parent_id : NodeId ) {
407
398
let field_data = self . save_ctxt . get_field_data ( field, parent_id) ;
408
399
if let Some ( field_data) = field_data {
@@ -792,7 +783,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
792
783
}
793
784
}
794
785
795
- fn process_path ( & mut self , id : NodeId , path : & ast:: Path ) {
786
+ fn process_path ( & mut self , id : NodeId , path : & ' l ast:: Path ) {
787
+ debug ! ( "process_path {:?}" , path) ;
796
788
let path_data = self . save_ctxt . get_path_data ( id, path) ;
797
789
if generated_code ( path. span ) && path_data. is_none ( ) {
798
790
return ;
@@ -807,6 +799,27 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
807
799
808
800
self . dumper . dump_ref ( path_data) ;
809
801
802
+ // Type parameters
803
+ for seg in & path. segments {
804
+ if let Some ( ref params) = seg. parameters {
805
+ match * * params {
806
+ ast:: PathParameters :: AngleBracketed ( ref data) => {
807
+ for t in & data. types {
808
+ self . visit_ty ( t) ;
809
+ }
810
+ }
811
+ ast:: PathParameters :: Parenthesized ( ref data) => {
812
+ for t in & data. inputs {
813
+ self . visit_ty ( t) ;
814
+ }
815
+ if let Some ( ref t) = data. output {
816
+ self . visit_ty ( t) ;
817
+ }
818
+ }
819
+ }
820
+ }
821
+ }
822
+
810
823
// Modules or types in the path prefix.
811
824
match self . save_ctxt . get_path_def ( id) {
812
825
HirDef :: Method ( did) => {
@@ -859,14 +872,26 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
859
872
walk_list ! ( self , visit_expr, base) ;
860
873
}
861
874
862
- fn process_method_call ( & mut self , ex : & ' l ast:: Expr , args : & ' l [ P < ast:: Expr > ] ) {
875
+ fn process_method_call ( & mut self ,
876
+ ex : & ' l ast:: Expr ,
877
+ seg : & ' l ast:: PathSegment ,
878
+ args : & ' l [ P < ast:: Expr > ] ) {
863
879
if let Some ( mcd) = self . save_ctxt . get_expr_data ( ex) {
864
880
down_cast_data ! ( mcd, RefData , ex. span) ;
865
881
if !generated_code ( ex. span ) {
866
882
self . dumper . dump_ref ( mcd) ;
867
883
}
868
884
}
869
885
886
+ // Explicit types in the turbo-fish.
887
+ if let Some ( ref params) = seg. parameters {
888
+ if let ast:: PathParameters :: AngleBracketed ( ref data) = * * params {
889
+ for t in & data. types {
890
+ self . visit_ty ( t) ;
891
+ }
892
+ }
893
+ }
894
+
870
895
// walk receiver and args
871
896
walk_list ! ( self , visit_expr, args) ;
872
897
}
@@ -913,7 +938,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
913
938
collector. visit_pat ( & p) ;
914
939
self . visit_pat ( & p) ;
915
940
916
- for & ( id, ref p , immut) in & collector. collected_paths {
941
+ for ( id, i , sp , immut) in collector. collected_idents {
917
942
let mut value = match immut {
918
943
ast:: Mutability :: Immutable => value. to_string ( ) ,
919
944
_ => String :: new ( ) ,
@@ -933,18 +958,18 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
933
958
934
959
// Get the span only for the name of the variable (I hope the path
935
960
// is only ever a variable name, but who knows?).
936
- let sub_span = self . span . span_for_last_ident ( p . span ) ;
961
+ let sub_span = self . span . span_for_last_ident ( sp ) ;
937
962
// Rust uses the id of the pattern for var lookups, so we'll use it too.
938
- if !self . span . filter_generated ( sub_span, p . span ) {
939
- let qualname = format ! ( "{}${}" , path_to_string ( p ) , id) ;
963
+ if !self . span . filter_generated ( sub_span, sp ) {
964
+ let qualname = format ! ( "{}${}" , i . to_string ( ) , id) ;
940
965
let id = :: id_from_node_id ( id, & self . save_ctxt ) ;
941
966
let span = self . span_from_span ( sub_span. expect ( "No span found for variable" ) ) ;
942
967
943
968
self . dumper . dump_def ( false , Def {
944
969
kind : DefKind :: Local ,
945
970
id,
946
971
span,
947
- name : path_to_string ( p ) ,
972
+ name : i . to_string ( ) ,
948
973
qualname,
949
974
value : typ,
950
975
parent : None ,
@@ -1274,7 +1299,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
1274
1299
for param in generics. ty_params . iter ( ) {
1275
1300
for bound in param. bounds . iter ( ) {
1276
1301
if let ast:: TraitTyParamBound ( ref trait_ref, _) = * bound {
1277
- self . process_trait_ref ( & trait_ref. trait_ref ) ;
1302
+ self . process_path ( trait_ref . trait_ref . ref_id , & trait_ref. trait_ref . path )
1278
1303
}
1279
1304
}
1280
1305
if let Some ( ref ty) = param. default {
@@ -1329,7 +1354,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
1329
1354
let def = self . save_ctxt . get_path_def ( hir_expr. id ) ;
1330
1355
self . process_struct_lit ( ex, path, fields, adt. variant_of_def ( def) , base)
1331
1356
}
1332
- ast:: ExprKind :: MethodCall ( .. , ref args) => self . process_method_call ( ex, args) ,
1357
+ ast:: ExprKind :: MethodCall ( ref seg , ref args) => self . process_method_call ( ex, seg , args) ,
1333
1358
ast:: ExprKind :: Field ( ref sub_ex, _) => {
1334
1359
self . visit_expr ( & sub_ex) ;
1335
1360
@@ -1401,15 +1426,15 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
1401
1426
let value = self . span . snippet ( subexpression. span ) ;
1402
1427
self . process_var_decl ( pattern, value) ;
1403
1428
debug ! ( "for loop, walk sub-expr: {:?}" , subexpression. node) ;
1404
- visit :: walk_expr ( self , subexpression) ;
1429
+ self . visit_expr ( subexpression) ;
1405
1430
visit:: walk_block ( self , block) ;
1406
1431
}
1407
1432
ast:: ExprKind :: IfLet ( ref pattern, ref subexpression, ref block, ref opt_else) => {
1408
1433
let value = self . span . snippet ( subexpression. span ) ;
1409
1434
self . process_var_decl ( pattern, value) ;
1410
- visit :: walk_expr ( self , subexpression) ;
1435
+ self . visit_expr ( subexpression) ;
1411
1436
visit:: walk_block ( self , block) ;
1412
- opt_else. as_ref ( ) . map ( |el| visit :: walk_expr ( self , el) ) ;
1437
+ opt_else. as_ref ( ) . map ( |el| self . visit_expr ( el) ) ;
1413
1438
}
1414
1439
ast:: ExprKind :: Repeat ( ref element, ref count) => {
1415
1440
self . visit_expr ( element) ;
@@ -1441,15 +1466,12 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
1441
1466
self . visit_pat ( & pattern) ;
1442
1467
}
1443
1468
1444
- // This is to get around borrow checking, because we need mut self to call process_path.
1445
- let mut paths_to_process = vec ! [ ] ;
1446
-
1447
1469
// process collected paths
1448
- for & ( id, ref p , immut) in & collector. collected_paths {
1470
+ for ( id, i , sp , immut) in collector. collected_idents {
1449
1471
match self . save_ctxt . get_path_def ( id) {
1450
1472
HirDef :: Local ( id) => {
1451
1473
let mut value = if immut == ast:: Mutability :: Immutable {
1452
- self . span . snippet ( p . span ) . to_string ( )
1474
+ self . span . snippet ( sp ) . to_string ( )
1453
1475
} else {
1454
1476
"<mutable>" . to_string ( )
1455
1477
} ;
@@ -1462,18 +1484,16 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
1462
1484
value. push_str ( ": " ) ;
1463
1485
value. push_str ( & typ) ;
1464
1486
1465
- assert ! ( p. segments. len( ) == 1 ,
1466
- "qualified path for local variable def in arm" ) ;
1467
- if !self . span . filter_generated ( Some ( p. span ) , p. span ) {
1468
- let qualname = format ! ( "{}${}" , path_to_string( p) , id) ;
1487
+ if !self . span . filter_generated ( Some ( sp) , sp) {
1488
+ let qualname = format ! ( "{}${}" , i. to_string( ) , id) ;
1469
1489
let id = :: id_from_node_id ( id, & self . save_ctxt ) ;
1470
- let span = self . span_from_span ( p . span ) ;
1490
+ let span = self . span_from_span ( sp ) ;
1471
1491
1472
1492
self . dumper . dump_def ( false , Def {
1473
1493
kind : DefKind :: Local ,
1474
1494
id,
1475
1495
span,
1476
- name : path_to_string ( p ) ,
1496
+ name : i . to_string ( ) ,
1477
1497
qualname,
1478
1498
value : typ,
1479
1499
parent : None ,
@@ -1485,19 +1505,12 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
1485
1505
} ) ;
1486
1506
}
1487
1507
}
1488
- HirDef :: StructCtor ( ..) | HirDef :: VariantCtor ( ..) |
1489
- HirDef :: Const ( ..) | HirDef :: AssociatedConst ( ..) |
1490
- HirDef :: Struct ( ..) | HirDef :: Variant ( ..) |
1491
- HirDef :: TyAlias ( ..) | HirDef :: AssociatedTy ( ..) |
1492
- HirDef :: SelfTy ( ..) => {
1493
- paths_to_process. push ( ( id, p. clone ( ) ) )
1494
- }
1495
- def => error ! ( "unexpected definition kind when processing collected paths: {:?}" ,
1508
+ def => error ! ( "unexpected definition kind when processing collected idents: {:?}" ,
1496
1509
def) ,
1497
1510
}
1498
1511
}
1499
1512
1500
- for & ( id, ref path) in & paths_to_process {
1513
+ for ( id, ref path) in collector . collected_paths {
1501
1514
self . process_path ( id, path) ;
1502
1515
}
1503
1516
walk_list ! ( self , visit_expr, & arm. guard) ;
0 commit comments