@@ -128,7 +128,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
128
128
self . save_ctxt . lookup_def_id ( ref_id)
129
129
}
130
130
131
- pub fn dump_crate_info ( & mut self , name : & str , krate : & hir:: Crate < ' _ > ) {
131
+ pub fn dump_crate_info ( & mut self , name : & str , _krate : & hir:: Crate < ' _ > ) {
132
132
let source_file = self . tcx . sess . local_crate_source_file . as_ref ( ) ;
133
133
let crate_root = source_file. map ( |source_file| {
134
134
let source_file = Path :: new ( source_file) ;
@@ -151,7 +151,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
151
151
} ,
152
152
crate_root : crate_root. unwrap_or_else ( || "<no source>" . to_owned ( ) ) ,
153
153
external_crates : self . save_ctxt . get_external_crates ( ) ,
154
- span : self . span_from_span ( krate . item . span ) ,
154
+ span : self . span_from_span ( self . tcx . hir ( ) . span ( hir :: CRATE_HIR_ID ) ) ,
155
155
} ;
156
156
157
157
self . dumper . crate_prelude ( data) ;
@@ -366,7 +366,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
366
366
self . nest_tables ( map. local_def_id ( item. hir_id ) , |v| {
367
367
let body = map. body ( body) ;
368
368
if let Some ( fn_data) = v. save_ctxt . get_item_data ( item) {
369
- down_cast_data ! ( fn_data, DefData , item . span) ;
369
+ down_cast_data ! ( fn_data, DefData , v . tcx . hir ( ) . span( item . hir_id ) ) ;
370
370
v. process_formals ( body. params , & fn_data. qualname ) ;
371
371
v. process_generic_params ( ty_params, & fn_data. qualname , item. hir_id ) ;
372
372
@@ -393,7 +393,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
393
393
) {
394
394
self . nest_tables ( self . tcx . hir ( ) . local_def_id ( item. hir_id ) , |v| {
395
395
if let Some ( var_data) = v. save_ctxt . get_item_data ( item) {
396
- down_cast_data ! ( var_data, DefData , item . span) ;
396
+ down_cast_data ! ( var_data, DefData , v . tcx . hir ( ) . span( item . hir_id ) ) ;
397
397
v. dumper . dump_def ( & access_from ! ( v. save_ctxt, item, item. hir_id) , var_data) ;
398
398
}
399
399
v. visit_ty ( & typ) ;
@@ -453,7 +453,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
453
453
def : & ' tcx hir:: VariantData < ' tcx > ,
454
454
ty_params : & ' tcx hir:: Generics < ' tcx > ,
455
455
) {
456
- debug ! ( "process_struct {:?} {:?}" , item, item . span) ;
456
+ debug ! ( "process_struct {:?} {:?}" , item, self . tcx . hir ( ) . span( item . hir_id ) ) ;
457
457
let name = item. ident . to_string ( ) ;
458
458
let qualname = format ! (
459
459
"::{}" ,
@@ -529,7 +529,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
529
529
None => return ,
530
530
Some ( data) => data,
531
531
} ;
532
- down_cast_data ! ( enum_data, DefData , item . span) ;
532
+ down_cast_data ! ( enum_data, DefData , self . tcx . hir ( ) . span( item . hir_id ) ) ;
533
533
534
534
let access = access_from ! ( self . save_ctxt, item, item. hir_id) ;
535
535
@@ -630,12 +630,13 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
630
630
impl_items : & ' tcx [ hir:: ImplItemRef < ' tcx > ] ,
631
631
) {
632
632
if let Some ( impl_data) = self . save_ctxt . get_item_data ( item) {
633
- if !self . span . filter_generated ( item. span ) {
633
+ let item_span = self . tcx . hir ( ) . span ( item. hir_id ) ;
634
+ if !self . span . filter_generated ( item_span) {
634
635
if let super :: Data :: RelationData ( rel, imp) = impl_data {
635
636
self . dumper . dump_relation ( rel) ;
636
637
self . dumper . dump_impl ( imp) ;
637
638
} else {
638
- span_bug ! ( item . span , "unexpected data kind: {:?}" , impl_data) ;
639
+ span_bug ! ( item_span , "unexpected data kind: {:?}" , impl_data) ;
639
640
}
640
641
}
641
642
}
@@ -742,7 +743,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
742
743
// `item` is the module in question, represented as an( item.
743
744
fn process_mod ( & mut self , item : & ' tcx hir:: Item < ' tcx > ) {
744
745
if let Some ( mod_data) = self . save_ctxt . get_item_data ( item) {
745
- down_cast_data ! ( mod_data, DefData , item . span) ;
746
+ down_cast_data ! ( mod_data, DefData , self . tcx . hir ( ) . span( item . hir_id ) ) ;
746
747
self . dumper . dump_def ( & access_from ! ( self . save_ctxt, item, item. hir_id) , mod_data) ;
747
748
}
748
749
}
@@ -811,8 +812,8 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
811
812
if let hir:: QPath :: Resolved ( _, path) = path {
812
813
self . write_sub_paths_truncated ( path) ;
813
814
}
814
- down_cast_data ! ( struct_lit_data, RefData , ex . span) ;
815
- if !generated_code ( ex . span ) {
815
+ down_cast_data ! ( struct_lit_data, RefData , self . tcx . hir ( ) . span( ex . hir_id ) ) ;
816
+ if !generated_code ( self . tcx . hir ( ) . span ( ex . hir_id ) ) {
816
817
self . dumper . dump_ref ( struct_lit_data) ;
817
818
}
818
819
@@ -834,10 +835,11 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
834
835
seg : & ' tcx hir:: PathSegment < ' tcx > ,
835
836
args : & ' tcx [ hir:: Expr < ' tcx > ] ,
836
837
) {
837
- debug ! ( "process_method_call {:?} {:?}" , ex, ex. span) ;
838
+ let ex_span = self . tcx . hir ( ) . span ( ex. hir_id ) ;
839
+ debug ! ( "process_method_call {:?} {:?}" , ex, ex_span) ;
838
840
if let Some ( mcd) = self . save_ctxt . get_expr_data ( ex) {
839
- down_cast_data ! ( mcd, RefData , ex . span ) ;
840
- if !generated_code ( ex . span ) {
841
+ down_cast_data ! ( mcd, RefData , ex_span ) ;
842
+ if !generated_code ( ex_span ) {
841
843
self . dumper . dump_ref ( mcd) ;
842
844
}
843
845
}
@@ -961,7 +963,9 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
961
963
/// If the span is not macro-generated, do nothing, else use callee and
962
964
/// callsite spans to record macro definition and use data, using the
963
965
/// mac_uses and mac_defs sets to prevent multiples.
964
- fn process_macro_use ( & mut self , _span : Span ) {
966
+ fn process_macro_use ( & mut self , _hir_id : hir:: HirId ) {
967
+ //let span = self.tcx.hir().span(_hir_id);
968
+ //
965
969
// FIXME if we're not dumping the defs (see below), there is no point
966
970
// dumping refs either.
967
971
// let source_span = span.source_callsite();
@@ -998,8 +1002,8 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
998
1002
}
999
1003
1000
1004
fn process_trait_item ( & mut self , trait_item : & ' tcx hir:: TraitItem < ' tcx > , trait_id : DefId ) {
1001
- self . process_macro_use ( trait_item. span ) ;
1002
- let vis_span = trait_item . span . shrink_to_lo ( ) ;
1005
+ self . process_macro_use ( trait_item. hir_id ) ;
1006
+ let vis_span = self . tcx . hir ( ) . span ( trait_item . hir_id ) . shrink_to_lo ( ) ;
1003
1007
match trait_item. kind {
1004
1008
hir:: TraitItemKind :: Const ( ref ty, body) => {
1005
1009
let body = body. map ( |b| & self . tcx . hir ( ) . body ( b) . value ) ;
@@ -1025,7 +1029,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
1025
1029
trait_item. ident ,
1026
1030
& trait_item. generics ,
1027
1031
& respan,
1028
- trait_item . span ,
1032
+ self . tcx . hir ( ) . span ( trait_item . hir_id ) ,
1029
1033
) ;
1030
1034
}
1031
1035
hir:: TraitItemKind :: Type ( ref bounds, ref default_ty) => {
@@ -1049,7 +1053,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
1049
1053
span,
1050
1054
name,
1051
1055
qualname,
1052
- value : self . span . snippet ( trait_item . span ) ,
1056
+ value : self . span . snippet ( self . tcx . hir ( ) . span ( trait_item . hir_id ) ) ,
1053
1057
parent : Some ( id_from_def_id ( trait_id) ) ,
1054
1058
children : vec ! [ ] ,
1055
1059
decl_id : None ,
@@ -1077,7 +1081,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
1077
1081
}
1078
1082
1079
1083
fn process_impl_item ( & mut self , impl_item : & ' tcx hir:: ImplItem < ' tcx > , impl_id : DefId ) {
1080
- self . process_macro_use ( impl_item. span ) ;
1084
+ self . process_macro_use ( impl_item. hir_id ) ;
1081
1085
match impl_item. kind {
1082
1086
hir:: ImplItemKind :: Const ( ref ty, body) => {
1083
1087
let body = self . tcx . hir ( ) . body ( body) ;
@@ -1099,7 +1103,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
1099
1103
impl_item. ident ,
1100
1104
& impl_item. generics ,
1101
1105
& impl_item. vis ,
1102
- impl_item . span ,
1106
+ self . tcx . hir ( ) . span ( impl_item . hir_id ) ,
1103
1107
) ;
1104
1108
}
1105
1109
hir:: ImplItemKind :: TyAlias ( ref ty) => {
@@ -1117,7 +1121,9 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
1117
1121
format ! ( "::{}" , self . tcx. def_path_str( self . tcx. hir( ) . local_def_id( id) . to_def_id( ) ) ) ;
1118
1122
1119
1123
let sm = self . tcx . sess . source_map ( ) ;
1120
- let filename = sm. span_to_filename ( krate. item . span ) ;
1124
+ let span = self . tcx . hir ( ) . span ( hir:: CRATE_HIR_ID ) ;
1125
+ let filename = sm. span_to_filename ( span) ;
1126
+ let span = self . span_from_span ( span) ;
1121
1127
let data_id = id_from_hir_id ( id, & self . save_ctxt ) ;
1122
1128
let children = krate
1123
1129
. item
@@ -1126,7 +1132,6 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
1126
1132
. iter ( )
1127
1133
. map ( |i| id_from_hir_id ( i. id , & self . save_ctxt ) )
1128
1134
. collect ( ) ;
1129
- let span = self . span_from_span ( krate. item . span ) ;
1130
1135
1131
1136
self . dumper . dump_def (
1132
1137
& Access { public : true , reachable : true } ,
@@ -1168,7 +1173,7 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
1168
1173
}
1169
1174
1170
1175
fn visit_item ( & mut self , item : & ' tcx hir:: Item < ' tcx > ) {
1171
- self . process_macro_use ( item. span ) ;
1176
+ self . process_macro_use ( item. hir_id ) ;
1172
1177
match item. kind {
1173
1178
hir:: ItemKind :: Use ( path, hir:: UseKind :: Single ) => {
1174
1179
let sub_span = path. segments . last ( ) . unwrap ( ) . ident . span ;
@@ -1206,10 +1211,11 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
1206
1211
1207
1212
// Otherwise it's a span with wrong macro expansion info, which
1208
1213
// we don't want to track anyway, since it's probably macro-internal `use`
1214
+ let item_span = self . tcx . hir ( ) . span ( item. hir_id ) ;
1209
1215
if let Some ( sub_span) =
1210
- self . span . sub_span_of_token ( item . span , token:: BinOp ( token:: Star ) )
1216
+ self . span . sub_span_of_token ( item_span , token:: BinOp ( token:: Star ) )
1211
1217
{
1212
- if !self . span . filter_generated ( item . span ) {
1218
+ if !self . span . filter_generated ( item_span ) {
1213
1219
let access = access_from ! ( self . save_ctxt, item, item. hir_id) ;
1214
1220
let span = self . span_from_span ( sub_span) ;
1215
1221
let parent = self
@@ -1347,10 +1353,10 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
1347
1353
}
1348
1354
1349
1355
fn visit_ty ( & mut self , t : & ' tcx hir:: Ty < ' tcx > ) {
1350
- self . process_macro_use ( t. span ) ;
1356
+ self . process_macro_use ( t. hir_id ) ;
1351
1357
match t. kind {
1352
1358
hir:: TyKind :: Path ( ref path) => {
1353
- if generated_code ( t . span ) {
1359
+ if generated_code ( self . tcx . hir ( ) . span ( t . hir_id ) ) {
1354
1360
return ;
1355
1361
}
1356
1362
@@ -1389,7 +1395,7 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
1389
1395
1390
1396
fn visit_expr ( & mut self , ex : & ' tcx hir:: Expr < ' tcx > ) {
1391
1397
debug ! ( "visit_expr {:?}" , ex. kind) ;
1392
- self . process_macro_use ( ex. span ) ;
1398
+ self . process_macro_use ( ex. hir_id ) ;
1393
1399
match ex. kind {
1394
1400
hir:: ExprKind :: Struct ( ref path, ref fields, ref base) => {
1395
1401
let hir_expr = self . save_ctxt . tcx . hir ( ) . expect_expr ( ex. hir_id ) ;
@@ -1410,8 +1416,9 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
1410
1416
self . visit_expr ( & sub_ex) ;
1411
1417
1412
1418
if let Some ( field_data) = self . save_ctxt . get_expr_data ( ex) {
1413
- down_cast_data ! ( field_data, RefData , ex. span) ;
1414
- if !generated_code ( ex. span ) {
1419
+ let ex_span = self . tcx . hir ( ) . span ( ex. hir_id ) ;
1420
+ down_cast_data ! ( field_data, RefData , ex_span) ;
1421
+ if !generated_code ( ex_span) {
1415
1422
self . dumper . dump_ref ( field_data) ;
1416
1423
}
1417
1424
}
@@ -1450,7 +1457,7 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
1450
1457
}
1451
1458
1452
1459
fn visit_pat ( & mut self , p : & ' tcx hir:: Pat < ' tcx > ) {
1453
- self . process_macro_use ( p. span ) ;
1460
+ self . process_macro_use ( p. hir_id ) ;
1454
1461
self . process_pat ( p) ;
1455
1462
}
1456
1463
@@ -1467,12 +1474,12 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
1467
1474
}
1468
1475
1469
1476
fn visit_stmt ( & mut self , s : & ' tcx hir:: Stmt < ' tcx > ) {
1470
- self . process_macro_use ( s. span ) ;
1477
+ self . process_macro_use ( s. hir_id ) ;
1471
1478
intravisit:: walk_stmt ( self , s)
1472
1479
}
1473
1480
1474
1481
fn visit_local ( & mut self , l : & ' tcx hir:: Local < ' tcx > ) {
1475
- self . process_macro_use ( l. span ) ;
1482
+ self . process_macro_use ( l. hir_id ) ;
1476
1483
self . process_var_decl ( & l. pat ) ;
1477
1484
1478
1485
// Just walk the initialiser and type (don't want to walk the pattern again).
@@ -1486,7 +1493,7 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
1486
1493
match item. kind {
1487
1494
hir:: ForeignItemKind :: Fn ( decl, _, ref generics) => {
1488
1495
if let Some ( fn_data) = self . save_ctxt . get_extern_item_data ( item) {
1489
- down_cast_data ! ( fn_data, DefData , item . span) ;
1496
+ down_cast_data ! ( fn_data, DefData , self . tcx . hir ( ) . span( item . hir_id ) ) ;
1490
1497
1491
1498
self . process_generic_params ( generics, & fn_data. qualname , item. hir_id ) ;
1492
1499
self . dumper . dump_def ( & access, fn_data) ;
@@ -1502,15 +1509,15 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
1502
1509
}
1503
1510
hir:: ForeignItemKind :: Static ( ref ty, _) => {
1504
1511
if let Some ( var_data) = self . save_ctxt . get_extern_item_data ( item) {
1505
- down_cast_data ! ( var_data, DefData , item . span) ;
1512
+ down_cast_data ! ( var_data, DefData , self . tcx . hir ( ) . span( item . hir_id ) ) ;
1506
1513
self . dumper . dump_def ( & access, var_data) ;
1507
1514
}
1508
1515
1509
1516
self . visit_ty ( ty) ;
1510
1517
}
1511
1518
hir:: ForeignItemKind :: Type => {
1512
1519
if let Some ( var_data) = self . save_ctxt . get_extern_item_data ( item) {
1513
- down_cast_data ! ( var_data, DefData , item . span) ;
1520
+ down_cast_data ! ( var_data, DefData , self . tcx . hir ( ) . span( item . hir_id ) ) ;
1514
1521
self . dumper . dump_def ( & access, var_data) ;
1515
1522
}
1516
1523
}
0 commit comments