@@ -128,7 +128,7 @@ impl<'tcx> DumpVisitor<'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<'tcx> DumpVisitor<'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) ;
@@ -376,7 +376,7 @@ impl<'tcx> DumpVisitor<'tcx> {
376
376
self . nest_typeck_results ( map. local_def_id ( item. hir_id ) , |v| {
377
377
let body = map. body ( body) ;
378
378
if let Some ( fn_data) = v. save_ctxt . get_item_data ( item) {
379
- down_cast_data ! ( fn_data, DefData , item . span) ;
379
+ down_cast_data ! ( fn_data, DefData , v . tcx . hir ( ) . span( item . hir_id ) ) ;
380
380
v. process_formals ( body. params , & fn_data. qualname ) ;
381
381
v. process_generic_params ( ty_params, & fn_data. qualname , item. hir_id ) ;
382
382
@@ -403,7 +403,7 @@ impl<'tcx> DumpVisitor<'tcx> {
403
403
) {
404
404
self . nest_typeck_results ( self . tcx . hir ( ) . local_def_id ( item. hir_id ) , |v| {
405
405
if let Some ( var_data) = v. save_ctxt . get_item_data ( item) {
406
- down_cast_data ! ( var_data, DefData , item . span) ;
406
+ down_cast_data ! ( var_data, DefData , v . tcx . hir ( ) . span( item . hir_id ) ) ;
407
407
v. dumper . dump_def ( & access_from ! ( v. save_ctxt, item, item. hir_id) , var_data) ;
408
408
}
409
409
v. visit_ty ( & typ) ;
@@ -463,7 +463,7 @@ impl<'tcx> DumpVisitor<'tcx> {
463
463
def : & ' tcx hir:: VariantData < ' tcx > ,
464
464
ty_params : & ' tcx hir:: Generics < ' tcx > ,
465
465
) {
466
- debug ! ( "process_struct {:?} {:?}" , item, item . span) ;
466
+ debug ! ( "process_struct {:?} {:?}" , item, self . tcx . hir ( ) . span( item . hir_id ) ) ;
467
467
let name = item. ident . to_string ( ) ;
468
468
let qualname = format ! (
469
469
"::{}" ,
@@ -539,7 +539,7 @@ impl<'tcx> DumpVisitor<'tcx> {
539
539
None => return ,
540
540
Some ( data) => data,
541
541
} ;
542
- down_cast_data ! ( enum_data, DefData , item . span) ;
542
+ down_cast_data ! ( enum_data, DefData , self . tcx . hir ( ) . span( item . hir_id ) ) ;
543
543
544
544
let access = access_from ! ( self . save_ctxt, item, item. hir_id) ;
545
545
@@ -640,12 +640,13 @@ impl<'tcx> DumpVisitor<'tcx> {
640
640
impl_items : & ' tcx [ hir:: ImplItemRef < ' tcx > ] ,
641
641
) {
642
642
if let Some ( impl_data) = self . save_ctxt . get_item_data ( item) {
643
- if !self . span . filter_generated ( item. span ) {
643
+ let item_span = self . tcx . hir ( ) . span ( item. hir_id ) ;
644
+ if !self . span . filter_generated ( item_span) {
644
645
if let super :: Data :: RelationData ( rel, imp) = impl_data {
645
646
self . dumper . dump_relation ( rel) ;
646
647
self . dumper . dump_impl ( imp) ;
647
648
} else {
648
- span_bug ! ( item . span , "unexpected data kind: {:?}" , impl_data) ;
649
+ span_bug ! ( item_span , "unexpected data kind: {:?}" , impl_data) ;
649
650
}
650
651
}
651
652
}
@@ -756,7 +757,7 @@ impl<'tcx> DumpVisitor<'tcx> {
756
757
// `item` is the module in question, represented as an( item.
757
758
fn process_mod ( & mut self , item : & ' tcx hir:: Item < ' tcx > ) {
758
759
if let Some ( mod_data) = self . save_ctxt . get_item_data ( item) {
759
- down_cast_data ! ( mod_data, DefData , item . span) ;
760
+ down_cast_data ! ( mod_data, DefData , self . tcx . hir ( ) . span( item . hir_id ) ) ;
760
761
self . dumper . dump_def ( & access_from ! ( self . save_ctxt, item, item. hir_id) , mod_data) ;
761
762
}
762
763
}
@@ -822,8 +823,8 @@ impl<'tcx> DumpVisitor<'tcx> {
822
823
if let hir:: QPath :: Resolved ( _, path) = path {
823
824
self . write_sub_paths_truncated ( path) ;
824
825
}
825
- down_cast_data ! ( struct_lit_data, RefData , ex . span) ;
826
- if !generated_code ( ex . span ) {
826
+ down_cast_data ! ( struct_lit_data, RefData , self . tcx . hir ( ) . span( ex . hir_id ) ) ;
827
+ if !generated_code ( self . tcx . hir ( ) . span ( ex . hir_id ) ) {
827
828
self . dumper . dump_ref ( struct_lit_data) ;
828
829
}
829
830
@@ -847,10 +848,11 @@ impl<'tcx> DumpVisitor<'tcx> {
847
848
seg : & ' tcx hir:: PathSegment < ' tcx > ,
848
849
args : & ' tcx [ hir:: Expr < ' tcx > ] ,
849
850
) {
850
- debug ! ( "process_method_call {:?} {:?}" , ex, ex. span) ;
851
+ let ex_span = self . tcx . hir ( ) . span ( ex. hir_id ) ;
852
+ debug ! ( "process_method_call {:?} {:?}" , ex, ex_span) ;
851
853
if let Some ( mcd) = self . save_ctxt . get_expr_data ( ex) {
852
- down_cast_data ! ( mcd, RefData , ex . span ) ;
853
- if !generated_code ( ex . span ) {
854
+ down_cast_data ! ( mcd, RefData , ex_span ) ;
855
+ if !generated_code ( ex_span ) {
854
856
self . dumper . dump_ref ( mcd) ;
855
857
}
856
858
}
@@ -974,7 +976,9 @@ impl<'tcx> DumpVisitor<'tcx> {
974
976
/// If the span is not macro-generated, do nothing, else use callee and
975
977
/// callsite spans to record macro definition and use data, using the
976
978
/// mac_uses and mac_defs sets to prevent multiples.
977
- fn process_macro_use ( & mut self , _span : Span ) {
979
+ fn process_macro_use ( & mut self , _hir_id : hir:: HirId ) {
980
+ //let span = self.tcx.hir().span(_hir_id);
981
+ //
978
982
// FIXME if we're not dumping the defs (see below), there is no point
979
983
// dumping refs either.
980
984
// let source_span = span.source_callsite();
@@ -1011,8 +1015,8 @@ impl<'tcx> DumpVisitor<'tcx> {
1011
1015
}
1012
1016
1013
1017
fn process_trait_item ( & mut self , trait_item : & ' tcx hir:: TraitItem < ' tcx > , trait_id : DefId ) {
1014
- self . process_macro_use ( trait_item. span ) ;
1015
- let vis_span = trait_item . span . shrink_to_lo ( ) ;
1018
+ self . process_macro_use ( trait_item. hir_id ) ;
1019
+ let vis_span = self . tcx . hir ( ) . span ( trait_item . hir_id ) . shrink_to_lo ( ) ;
1016
1020
match trait_item. kind {
1017
1021
hir:: TraitItemKind :: Const ( ref ty, body) => {
1018
1022
let body = body. map ( |b| & self . tcx . hir ( ) . body ( b) . value ) ;
@@ -1038,7 +1042,7 @@ impl<'tcx> DumpVisitor<'tcx> {
1038
1042
trait_item. ident ,
1039
1043
& trait_item. generics ,
1040
1044
& respan,
1041
- trait_item . span ,
1045
+ self . tcx . hir ( ) . span ( trait_item . hir_id ) ,
1042
1046
) ;
1043
1047
}
1044
1048
hir:: TraitItemKind :: Type ( ref bounds, ref default_ty) => {
@@ -1062,7 +1066,7 @@ impl<'tcx> DumpVisitor<'tcx> {
1062
1066
span,
1063
1067
name,
1064
1068
qualname,
1065
- value : self . span . snippet ( trait_item . span ) ,
1069
+ value : self . span . snippet ( self . tcx . hir ( ) . span ( trait_item . hir_id ) ) ,
1066
1070
parent : Some ( id_from_def_id ( trait_id) ) ,
1067
1071
children : vec ! [ ] ,
1068
1072
decl_id : None ,
@@ -1090,7 +1094,7 @@ impl<'tcx> DumpVisitor<'tcx> {
1090
1094
}
1091
1095
1092
1096
fn process_impl_item ( & mut self , impl_item : & ' tcx hir:: ImplItem < ' tcx > , impl_id : DefId ) {
1093
- self . process_macro_use ( impl_item. span ) ;
1097
+ self . process_macro_use ( impl_item. hir_id ) ;
1094
1098
match impl_item. kind {
1095
1099
hir:: ImplItemKind :: Const ( ref ty, body) => {
1096
1100
let body = self . tcx . hir ( ) . body ( body) ;
@@ -1112,7 +1116,7 @@ impl<'tcx> DumpVisitor<'tcx> {
1112
1116
impl_item. ident ,
1113
1117
& impl_item. generics ,
1114
1118
& impl_item. vis ,
1115
- impl_item . span ,
1119
+ self . tcx . hir ( ) . span ( impl_item . hir_id ) ,
1116
1120
) ;
1117
1121
}
1118
1122
hir:: ImplItemKind :: TyAlias ( ref ty) => {
@@ -1130,7 +1134,9 @@ impl<'tcx> DumpVisitor<'tcx> {
1130
1134
format ! ( "::{}" , self . tcx. def_path_str( self . tcx. hir( ) . local_def_id( id) . to_def_id( ) ) ) ;
1131
1135
1132
1136
let sm = self . tcx . sess . source_map ( ) ;
1133
- let filename = sm. span_to_filename ( krate. item . span ) ;
1137
+ let span = self . tcx . hir ( ) . span ( hir:: CRATE_HIR_ID ) ;
1138
+ let filename = sm. span_to_filename ( span) ;
1139
+ let span = self . span_from_span ( span) ;
1134
1140
let data_id = id_from_hir_id ( id, & self . save_ctxt ) ;
1135
1141
let children = krate
1136
1142
. item
@@ -1139,7 +1145,6 @@ impl<'tcx> DumpVisitor<'tcx> {
1139
1145
. iter ( )
1140
1146
. map ( |i| id_from_hir_id ( i. id , & self . save_ctxt ) )
1141
1147
. collect ( ) ;
1142
- let span = self . span_from_span ( krate. item . span ) ;
1143
1148
1144
1149
self . dumper . dump_def (
1145
1150
& Access { public : true , reachable : true } ,
@@ -1181,7 +1186,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
1181
1186
}
1182
1187
1183
1188
fn visit_item ( & mut self , item : & ' tcx hir:: Item < ' tcx > ) {
1184
- self . process_macro_use ( item. span ) ;
1189
+ self . process_macro_use ( item. hir_id ) ;
1185
1190
match item. kind {
1186
1191
hir:: ItemKind :: Use ( path, hir:: UseKind :: Single ) => {
1187
1192
let sub_span = path. segments . last ( ) . unwrap ( ) . ident . span ;
@@ -1219,8 +1224,9 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
1219
1224
1220
1225
// Otherwise it's a span with wrong macro expansion info, which
1221
1226
// we don't want to track anyway, since it's probably macro-internal `use`
1222
- if let Some ( sub_span) = self . span . sub_span_of_star ( item. span ) {
1223
- if !self . span . filter_generated ( item. span ) {
1227
+ let item_span = self . tcx . hir ( ) . span ( item. hir_id ) ;
1228
+ if let Some ( sub_span) = self . span . sub_span_of_star ( item_span) {
1229
+ if !self . span . filter_generated ( item_span) {
1224
1230
let access = access_from ! ( self . save_ctxt, item, item. hir_id) ;
1225
1231
let span = self . span_from_span ( sub_span) ;
1226
1232
let parent = self
@@ -1361,10 +1367,10 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
1361
1367
}
1362
1368
1363
1369
fn visit_ty ( & mut self , t : & ' tcx hir:: Ty < ' tcx > ) {
1364
- self . process_macro_use ( t. span ) ;
1370
+ self . process_macro_use ( t. hir_id ) ;
1365
1371
match t. kind {
1366
1372
hir:: TyKind :: Path ( ref path) => {
1367
- if generated_code ( t . span ) {
1373
+ if generated_code ( self . tcx . hir ( ) . span ( t . hir_id ) ) {
1368
1374
return ;
1369
1375
}
1370
1376
@@ -1402,7 +1408,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
1402
1408
1403
1409
fn visit_expr ( & mut self , ex : & ' tcx hir:: Expr < ' tcx > ) {
1404
1410
debug ! ( "visit_expr {:?}" , ex. kind) ;
1405
- self . process_macro_use ( ex. span ) ;
1411
+ self . process_macro_use ( ex. hir_id ) ;
1406
1412
match ex. kind {
1407
1413
hir:: ExprKind :: Struct ( ref path, ref fields, ref rest) => {
1408
1414
let hir_expr = self . save_ctxt . tcx . hir ( ) . expect_expr ( ex. hir_id ) ;
@@ -1423,8 +1429,9 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
1423
1429
self . visit_expr ( & sub_ex) ;
1424
1430
1425
1431
if let Some ( field_data) = self . save_ctxt . get_expr_data ( ex) {
1426
- down_cast_data ! ( field_data, RefData , ex. span) ;
1427
- if !generated_code ( ex. span ) {
1432
+ let ex_span = self . tcx . hir ( ) . span ( ex. hir_id ) ;
1433
+ down_cast_data ! ( field_data, RefData , ex_span) ;
1434
+ if !generated_code ( ex_span) {
1428
1435
self . dumper . dump_ref ( field_data) ;
1429
1436
}
1430
1437
}
@@ -1463,7 +1470,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
1463
1470
}
1464
1471
1465
1472
fn visit_pat ( & mut self , p : & ' tcx hir:: Pat < ' tcx > ) {
1466
- self . process_macro_use ( p. span ) ;
1473
+ self . process_macro_use ( p. hir_id ) ;
1467
1474
self . process_pat ( p) ;
1468
1475
}
1469
1476
@@ -1480,12 +1487,12 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
1480
1487
}
1481
1488
1482
1489
fn visit_stmt ( & mut self , s : & ' tcx hir:: Stmt < ' tcx > ) {
1483
- self . process_macro_use ( s. span ) ;
1490
+ self . process_macro_use ( s. hir_id ) ;
1484
1491
intravisit:: walk_stmt ( self , s)
1485
1492
}
1486
1493
1487
1494
fn visit_local ( & mut self , l : & ' tcx hir:: Local < ' tcx > ) {
1488
- self . process_macro_use ( l. span ) ;
1495
+ self . process_macro_use ( l. hir_id ) ;
1489
1496
self . process_var_decl ( & l. pat ) ;
1490
1497
1491
1498
// Just walk the initialiser and type (don't want to walk the pattern again).
@@ -1499,7 +1506,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
1499
1506
match item. kind {
1500
1507
hir:: ForeignItemKind :: Fn ( decl, _, ref generics) => {
1501
1508
if let Some ( fn_data) = self . save_ctxt . get_extern_item_data ( item) {
1502
- down_cast_data ! ( fn_data, DefData , item . span) ;
1509
+ down_cast_data ! ( fn_data, DefData , self . tcx . hir ( ) . span( item . hir_id ) ) ;
1503
1510
1504
1511
self . process_generic_params ( generics, & fn_data. qualname , item. hir_id ) ;
1505
1512
self . dumper . dump_def ( & access, fn_data) ;
@@ -1515,15 +1522,15 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
1515
1522
}
1516
1523
hir:: ForeignItemKind :: Static ( ref ty, _) => {
1517
1524
if let Some ( var_data) = self . save_ctxt . get_extern_item_data ( item) {
1518
- down_cast_data ! ( var_data, DefData , item . span) ;
1525
+ down_cast_data ! ( var_data, DefData , self . tcx . hir ( ) . span( item . hir_id ) ) ;
1519
1526
self . dumper . dump_def ( & access, var_data) ;
1520
1527
}
1521
1528
1522
1529
self . visit_ty ( ty) ;
1523
1530
}
1524
1531
hir:: ForeignItemKind :: Type => {
1525
1532
if let Some ( var_data) = self . save_ctxt . get_extern_item_data ( item) {
1526
- down_cast_data ! ( var_data, DefData , item . span) ;
1533
+ down_cast_data ! ( var_data, DefData , self . tcx . hir ( ) . span( item . hir_id ) ) ;
1527
1534
self . dumper . dump_def ( & access, var_data) ;
1528
1535
}
1529
1536
}
0 commit comments