@@ -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) ;
@@ -434,9 +440,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
434
440
if !self . span . filter_generated ( ident. span ) {
435
441
let sig = sig:: assoc_const_signature ( id, ident. name , typ, expr, & self . save_ctxt ) ;
436
442
let span = self . span_from_span ( ident. span ) ;
443
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
437
444
438
445
self . dumper . dump_def (
439
- & access_from ! ( self . save_ctxt, vis, id ) ,
446
+ & access_from_vis ! ( self . save_ctxt, vis, hir_id ) ,
440
447
Def {
441
448
kind : DefKind :: Const ,
442
449
id : id_from_node_id ( id, & self . save_ctxt ) ,
@@ -510,8 +517,9 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
510
517
511
518
if !self . span . filter_generated ( item. ident . span ) {
512
519
let span = self . span_from_span ( item. ident . span ) ;
520
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
513
521
self . dumper . dump_def (
514
- & access_from ! ( self . save_ctxt, item) ,
522
+ & access_from ! ( self . save_ctxt, item, hir_id ) ,
515
523
Def {
516
524
kind,
517
525
id : id_from_node_id ( item. id , & self . save_ctxt ) ,
@@ -550,7 +558,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
550
558
} ;
551
559
down_cast_data ! ( enum_data, DefData , item. span) ;
552
560
553
- let access = access_from ! ( self . save_ctxt, item) ;
561
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
562
+ let access = access_from ! ( self . save_ctxt, item, hir_id) ;
554
563
555
564
for variant in & enum_definition. variants {
556
565
let name = variant. node . ident . name . to_string ( ) ;
@@ -698,8 +707,9 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
698
707
. iter ( )
699
708
. map ( |i| id_from_node_id ( i. id , & self . save_ctxt ) )
700
709
. collect ( ) ;
710
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
701
711
self . dumper . dump_def (
702
- & access_from ! ( self . save_ctxt, item) ,
712
+ & access_from ! ( self . save_ctxt, item, hir_id ) ,
703
713
Def {
704
714
kind : DefKind :: Trait ,
705
715
id,
@@ -757,7 +767,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
757
767
fn process_mod ( & mut self , item : & ast:: Item ) {
758
768
if let Some ( mod_data) = self . save_ctxt . get_item_data ( item) {
759
769
down_cast_data ! ( mod_data, DefData , item. span) ;
760
- self . dumper . dump_def ( & access_from ! ( self . save_ctxt, item) , mod_data) ;
770
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
771
+ self . dumper . dump_def ( & access_from ! ( self . save_ctxt, item, hir_id) , mod_data) ;
761
772
}
762
773
}
763
774
@@ -1197,7 +1208,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
1197
1208
1198
1209
// The access is calculated using the current tree ID, but with the root tree's visibility
1199
1210
// (since nested trees don't have their own visibility).
1200
- let access = access_from ! ( self . save_ctxt, root_item. vis, id) ;
1211
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
1212
+ let access = access_from ! ( self . save_ctxt, root_item, hir_id) ;
1201
1213
1202
1214
// The parent def id of a given use tree is always the enclosing item.
1203
1215
let parent = self . save_ctxt . tcx . hir ( ) . opt_local_def_id ( id)
@@ -1394,9 +1406,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
1394
1406
if !self . span . filter_generated ( item. ident . span ) {
1395
1407
let span = self . span_from_span ( item. ident . span ) ;
1396
1408
let id = id_from_node_id ( item. id , & self . save_ctxt ) ;
1409
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
1397
1410
1398
1411
self . dumper . dump_def (
1399
- & access_from ! ( self . save_ctxt, item) ,
1412
+ & access_from ! ( self . save_ctxt, item, hir_id ) ,
1400
1413
Def {
1401
1414
kind : DefKind :: Type ,
1402
1415
id,
@@ -1424,9 +1437,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
1424
1437
if !self . span . filter_generated ( item. ident . span ) {
1425
1438
let span = self . span_from_span ( item. ident . span ) ;
1426
1439
let id = id_from_node_id ( item. id , & self . save_ctxt ) ;
1440
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
1427
1441
1428
1442
self . dumper . dump_def (
1429
- & access_from ! ( self . save_ctxt, item) ,
1443
+ & access_from ! ( self . save_ctxt, item, hir_id ) ,
1430
1444
Def {
1431
1445
kind : DefKind :: Type ,
1432
1446
id,
@@ -1624,7 +1638,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
1624
1638
}
1625
1639
1626
1640
fn visit_foreign_item ( & mut self , item : & ' l ast:: ForeignItem ) {
1627
- let access = access_from ! ( self . save_ctxt, item) ;
1641
+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
1642
+ let access = access_from ! ( self . save_ctxt, item, hir_id) ;
1628
1643
1629
1644
match item. node {
1630
1645
ast:: ForeignItemKind :: Fn ( ref decl, ref generics) => {
0 commit comments