@@ -1034,7 +1034,7 @@ pub struct Resolver<'a> {
1034
1034
1035
1035
main_def : Option < MainDefinition > ,
1036
1036
1037
- node_privacy : FxHashMap < DefId , AccessLevel >
1037
+ node_privacy : FxHashMap < HirId , AccessLevel > ,
1038
1038
}
1039
1039
1040
1040
/// Nothing really interesting here; it just provides memory for the rest of the crate.
@@ -1535,40 +1535,64 @@ impl<'a> Resolver<'a> {
1535
1535
1536
1536
if let Some ( def_id) = root. def_id ( ) {
1537
1537
if let Some ( exports) = self . export_map . get ( & def_id. expect_local ( ) ) . cloned ( ) {
1538
- tracing :: trace! ( "exports={:?}" , exports ) ;
1539
- let public_exports = exports. iter ( ) . filter ( |ex| ex. vis == Visibility :: Public ) . collect :: < Vec < _ > > ( ) ;
1538
+ let public_exports =
1539
+ exports. iter ( ) . filter ( |ex| ex. vis == Visibility :: Public ) . collect :: < Vec < _ > > ( ) ;
1540
1540
for export in public_exports. into_iter ( ) {
1541
- self . per_ns ( |this , ns| {
1542
- let new_key = this . new_key ( export. ident , ns) ;
1543
- let name_res = this . resolution ( root, new_key ) ;
1541
+ if let Some ( ns ) = export . res . ns ( ) {
1542
+ let key = self . new_key ( export. ident , ns) ;
1543
+ let name_res = self . resolution ( root, key ) ;
1544
1544
if let Some ( binding) = name_res. borrow ( ) . binding ( ) {
1545
- this . recursive_define_access_level ( binding, AccessLevel :: Public , 30 ) ;
1545
+ self . recursive_define_access_level ( binding, AccessLevel :: Public , 30 ) ;
1546
1546
}
1547
- } ) ;
1547
+ }
1548
1548
}
1549
1549
}
1550
1550
}
1551
1551
1552
1552
tracing:: info!( "node_privacy: {:#?}" , self . node_privacy) ;
1553
1553
}
1554
1554
1555
- fn recursive_define_access_level ( & mut self , binding : & NameBinding < ' a > , access_level : AccessLevel , max_recurse : usize ) {
1555
+ fn recursive_define_access_level (
1556
+ & mut self ,
1557
+ binding : & NameBinding < ' a > ,
1558
+ access_level : AccessLevel ,
1559
+ max_recurse : usize ,
1560
+ ) {
1556
1561
// Is this useful in case of very very veryyyyyy deep nesting?
1557
1562
if max_recurse == 0 {
1558
1563
return ;
1559
1564
}
1560
1565
1561
1566
if let NameBindingKind :: Import { binding, import, .. } = binding. kind {
1562
- let def_id = self . opt_local_def_id ( import. id ) . map ( |local_def_id| local_def_id. to_def_id ( ) ) ;
1563
- if let Some ( def_id) = def_id {
1564
- tracing:: trace!( "binding found! import.id={:?} def_id={:?}" , import. id, def_id) ;
1565
- self . node_privacy . insert ( def_id, access_level) ;
1566
- }
1567
+ tracing:: trace!(
1568
+ "binding found! import.id={:?}, import.root_id={:?}, res={:?}" ,
1569
+ import. id,
1570
+ import. root_id,
1571
+ binding. res( )
1572
+ ) ;
1573
+ self . mark_node_with_access_level ( import. id , access_level) ;
1574
+ match import. kind {
1575
+ ImportKind :: Single { additional_ids, .. } => {
1576
+ self . mark_node_with_access_level ( additional_ids. 0 , access_level) ;
1577
+ self . mark_node_with_access_level ( additional_ids. 1 , access_level) ;
1578
+ }
1579
+ _ => { }
1580
+ } ;
1567
1581
1568
1582
self . recursive_define_access_level ( binding, AccessLevel :: Exported , max_recurse - 1 ) ;
1569
1583
}
1570
1584
}
1571
1585
1586
+ fn mark_node_with_access_level ( & mut self , node_id : NodeId , access_level : AccessLevel ) -> bool {
1587
+ if let Some ( local_def_id) = self . opt_local_def_id ( node_id) {
1588
+ if let Some ( hir_id) = self . definitions ( ) . def_id_to_hir_id . get ( local_def_id. to_def_id ( ) ) {
1589
+ self . node_privacy . insert ( hir_id, access_level) . is_none ( ) ;
1590
+ }
1591
+ } else {
1592
+ false
1593
+ }
1594
+ }
1595
+
1572
1596
pub fn traits_in_scope (
1573
1597
& mut self ,
1574
1598
current_trait : Option < Module < ' a > > ,
0 commit comments