@@ -1034,7 +1034,7 @@ pub struct Resolver<'a> {
10341034
10351035 main_def : Option < MainDefinition > ,
10361036
1037- node_privacy : FxHashMap < DefId , AccessLevel >
1037+ node_privacy : FxHashMap < HirId , AccessLevel > ,
10381038}
10391039
10401040/// Nothing really interesting here; it just provides memory for the rest of the crate.
@@ -1535,40 +1535,64 @@ impl<'a> Resolver<'a> {
15351535
15361536 if let Some ( def_id) = root. def_id ( ) {
15371537 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 < _ > > ( ) ;
15401540 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 ) ;
15441544 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 ) ;
15461546 }
1547- } ) ;
1547+ }
15481548 }
15491549 }
15501550 }
15511551
15521552 tracing:: info!( "node_privacy: {:#?}" , self . node_privacy) ;
15531553 }
15541554
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+ ) {
15561561 // Is this useful in case of very very veryyyyyy deep nesting?
15571562 if max_recurse == 0 {
15581563 return ;
15591564 }
15601565
15611566 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+ } ;
15671581
15681582 self . recursive_define_access_level ( binding, AccessLevel :: Exported , max_recurse - 1 ) ;
15691583 }
15701584 }
15711585
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+
15721596 pub fn traits_in_scope (
15731597 & mut self ,
15741598 current_trait : Option < Module < ' a > > ,
0 commit comments