@@ -58,17 +58,19 @@ macro_rules! down_cast_data {
58
58
}
59
59
60
60
macro_rules! access_from {
61
- ( $save_ctxt: expr, $vis : expr, $id: expr) => {
61
+ ( $save_ctxt: expr, $item : expr, $id: expr) => {
62
62
Access {
63
- public: $vis. node. is_pub( ) ,
63
+ public: $item . vis. node. is_pub( ) ,
64
64
reachable: $save_ctxt. access_levels. is_reachable( $id) ,
65
65
}
66
66
} ;
67
+ }
67
68
68
- ( $save_ctxt: expr, $item: expr) => {
69
+ macro_rules! access_from_vis {
70
+ ( $save_ctxt: expr, $vis: expr, $id: expr) => {
69
71
Access {
70
- public: $item . vis. node. is_pub( ) ,
71
- reachable: $save_ctxt. access_levels. is_reachable( $item . id) ,
72
+ public: $vis. node. is_pub( ) ,
73
+ reachable: $save_ctxt. access_levels. is_reachable( $id) ,
72
74
}
73
75
} ;
74
76
}
@@ -303,7 +305,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
303
305
304
306
method_data. value = sig_str;
305
307
method_data. sig = sig:: method_signature ( id, ident, generics, sig, & self . save_ctxt ) ;
306
- self . dumper . dump_def ( & access_from ! ( self . save_ctxt, vis, id) , method_data) ;
308
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
309
+ self . dumper . dump_def ( & access_from_vis ! ( self . save_ctxt, vis, hir_id) , method_data) ;
307
310
}
308
311
309
312
// walk arg and return types
@@ -324,7 +327,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
324
327
fn process_struct_field_def ( & mut self , field : & ast:: StructField , parent_id : NodeId ) {
325
328
let field_data = self . save_ctxt . get_field_data ( field, parent_id) ;
326
329
if let Some ( field_data) = field_data {
327
- self . dumper . dump_def ( & access_from ! ( self . save_ctxt, field) , field_data) ;
330
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( field. id ) ;
331
+ self . dumper . dump_def ( & access_from ! ( self . save_ctxt, field, hir_id) , field_data) ;
328
332
}
329
333
}
330
334
@@ -389,7 +393,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
389
393
|v| v. process_formals ( & decl. inputs , & fn_data. qualname ) ,
390
394
) ;
391
395
self . process_generic_params ( ty_params, & fn_data. qualname , item. id ) ;
392
- self . dumper . dump_def ( & access_from ! ( self . save_ctxt, item) , fn_data) ;
396
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
397
+ self . dumper . dump_def ( & access_from ! ( self . save_ctxt, item, hir_id) , fn_data) ;
393
398
}
394
399
395
400
for arg in & decl. inputs {
@@ -409,10 +414,11 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
409
414
typ : & ' l ast:: Ty ,
410
415
expr : & ' l ast:: Expr ,
411
416
) {
417
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
412
418
self . nest_tables ( item. id , |v| {
413
419
if let Some ( var_data) = v. save_ctxt . get_item_data ( item) {
414
420
down_cast_data ! ( var_data, DefData , item. span) ;
415
- v. dumper . dump_def ( & access_from ! ( v. save_ctxt, item) , var_data) ;
421
+ v. dumper . dump_def ( & access_from ! ( v. save_ctxt, item, hir_id ) , var_data) ;
416
422
}
417
423
v. visit_ty ( & typ) ;
418
424
v. visit_expr ( expr) ;
@@ -435,9 +441,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
435
441
if !self . span . filter_generated ( ident. span ) {
436
442
let sig = sig:: assoc_const_signature ( id, ident. name , typ, expr, & self . save_ctxt ) ;
437
443
let span = self . span_from_span ( ident. span ) ;
444
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
438
445
439
446
self . dumper . dump_def (
440
- & access_from ! ( self . save_ctxt, vis, id ) ,
447
+ & access_from_vis ! ( self . save_ctxt, vis, hir_id ) ,
441
448
Def {
442
449
kind : DefKind :: Const ,
443
450
id : id_from_node_id ( id, & self . save_ctxt ) ,
@@ -512,8 +519,9 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
512
519
513
520
if !self . span . filter_generated ( item. ident . span ) {
514
521
let span = self . span_from_span ( item. ident . span ) ;
522
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
515
523
self . dumper . dump_def (
516
- & access_from ! ( self . save_ctxt, item) ,
524
+ & access_from ! ( self . save_ctxt, item, hir_id ) ,
517
525
Def {
518
526
kind,
519
527
id : id_from_node_id ( item. id , & self . save_ctxt ) ,
@@ -552,7 +560,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
552
560
} ;
553
561
down_cast_data ! ( enum_data, DefData , item. span) ;
554
562
555
- let access = access_from ! ( self . save_ctxt, item) ;
563
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
564
+ let access = access_from ! ( self . save_ctxt, item, hir_id) ;
556
565
557
566
for variant in & enum_definition. variants {
558
567
let name = variant. node . ident . name . to_string ( ) ;
@@ -701,8 +710,9 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
701
710
. iter ( )
702
711
. map ( |i| id_from_node_id ( i. id , & self . save_ctxt ) )
703
712
. collect ( ) ;
713
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
704
714
self . dumper . dump_def (
705
- & access_from ! ( self . save_ctxt, item) ,
715
+ & access_from ! ( self . save_ctxt, item, hir_id ) ,
706
716
Def {
707
717
kind : DefKind :: Trait ,
708
718
id,
@@ -760,7 +770,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
760
770
fn process_mod ( & mut self , item : & ast:: Item ) {
761
771
if let Some ( mod_data) = self . save_ctxt . get_item_data ( item) {
762
772
down_cast_data ! ( mod_data, DefData , item. span) ;
763
- self . dumper . dump_def ( & access_from ! ( self . save_ctxt, item) , mod_data) ;
773
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
774
+ self . dumper . dump_def ( & access_from ! ( self . save_ctxt, item, hir_id) , mod_data) ;
764
775
}
765
776
}
766
777
@@ -1201,7 +1212,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
1201
1212
1202
1213
// The access is calculated using the current tree ID, but with the root tree's visibility
1203
1214
// (since nested trees don't have their own visibility).
1204
- let access = access_from ! ( self . save_ctxt, root_item. vis, id) ;
1215
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
1216
+ let access = access_from ! ( self . save_ctxt, root_item, hir_id) ;
1205
1217
1206
1218
// The parent def id of a given use tree is always the enclosing item.
1207
1219
let parent = self . save_ctxt . tcx . hir ( ) . opt_local_def_id ( id)
@@ -1400,9 +1412,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
1400
1412
if !self . span . filter_generated ( item. ident . span ) {
1401
1413
let span = self . span_from_span ( item. ident . span ) ;
1402
1414
let id = id_from_node_id ( item. id , & self . save_ctxt ) ;
1415
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
1403
1416
1404
1417
self . dumper . dump_def (
1405
- & access_from ! ( self . save_ctxt, item) ,
1418
+ & access_from ! ( self . save_ctxt, item, hir_id ) ,
1406
1419
Def {
1407
1420
kind : DefKind :: Type ,
1408
1421
id,
@@ -1431,9 +1444,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
1431
1444
if !self . span . filter_generated ( item. ident . span ) {
1432
1445
let span = self . span_from_span ( item. ident . span ) ;
1433
1446
let id = id_from_node_id ( item. id , & self . save_ctxt ) ;
1447
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
1434
1448
1435
1449
self . dumper . dump_def (
1436
- & access_from ! ( self . save_ctxt, item) ,
1450
+ & access_from ! ( self . save_ctxt, item, hir_id ) ,
1437
1451
Def {
1438
1452
kind : DefKind :: Type ,
1439
1453
id,
@@ -1631,7 +1645,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
1631
1645
}
1632
1646
1633
1647
fn visit_foreign_item ( & mut self , item : & ' l ast:: ForeignItem ) {
1634
- let access = access_from ! ( self . save_ctxt, item) ;
1648
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
1649
+ let access = access_from ! ( self . save_ctxt, item, hir_id) ;
1635
1650
1636
1651
match item. node {
1637
1652
ast:: ForeignItemKind :: Fn ( ref decl, ref generics) => {
0 commit comments