@@ -26,11 +26,6 @@ impl<'r, 'a> AccessLevelsVisitor<'r, 'a> {
2626 pub fn compute_access_levels < ' c > ( r : & ' r mut Resolver < ' a > , krate : & ' c Crate ) {
2727 let mut visitor = AccessLevelsVisitor { r, changed : false } ;
2828
29- /*
30- let crate_effective_vis = EffectiveVisibility::default();
31- crate_effective_vis.update(Visibility::Public, AccessLevel::Public, visitor.r);
32- visitor.r.access_levels.set_effective_vis(CRATE_DEF_ID, crate_effective_vis);
33- */
3429 visitor. set_access_level_def_id ( CRATE_DEF_ID , Some ( AccessLevel :: Public ) ) ;
3530 visitor. set_bindings_access_level ( CRATE_DEF_ID ) ;
3631
@@ -74,41 +69,30 @@ impl<'r, 'a> AccessLevelsVisitor<'r, 'a> {
7469 let module = self . r . get_module ( module_id. to_def_id ( ) ) . unwrap ( ) ;
7570 let resolutions = self . r . resolutions ( module) ;
7671
77- for ( key, name_resolution) in resolutions. borrow ( ) . iter ( ) {
78- if let Some ( binding) = name_resolution. borrow ( ) . binding ( ) && binding. vis . is_public ( ) && !binding. is_ambiguity ( ) && module_level. is_some ( ) {
79- let access_level = match binding. is_import ( ) {
72+ for ( .., name_resolution) in resolutions. borrow ( ) . iter ( ) {
73+
74+ if let Some ( binding) = name_resolution. borrow ( ) . binding ( ) {
75+ let tag = match binding. is_import ( ) {
8076 true => {
81- set_import_binding_access_level ( self , binding, module_level) ;
82- Some ( AccessLevel :: Exported )
77+ if binding. vis . is_public ( ) && !binding. is_ambiguity ( ) && module_level. is_some ( ) {
78+ set_import_binding_access_level ( self , binding, module_level) ;
79+ }
80+ AccessLevel :: Exported
8381 } ,
84- false => module_level ,
82+ false => AccessLevel :: Public
8583 } ;
86- if let Some ( def_id) = binding. res ( ) . opt_def_id ( ) . and_then ( |id| id. as_local ( ) ) {
87- self . set_access_level_def_id ( def_id, access_level) ;
88- }
89- }
9084
91- if let Some ( binding) = name_resolution. borrow ( ) . binding ( ) {
92- println ! ( "ident: {}" , key. ident. as_str( ) ) ;
9385 if let Some ( def_id) = binding. res ( ) . opt_def_id ( ) . and_then ( |id| id. as_local ( ) ) {
94- let tag = match binding. is_import ( ) {
95- true => AccessLevel :: Exported ,
96- false => AccessLevel :: Public ,
97- } ;
9886 let vis = match binding. vis {
9987 Visibility :: Public => Visibility :: Public ,
10088 Visibility :: Restricted ( id) => Visibility :: Restricted ( id. expect_local ( ) )
10189 } ;
10290 self . update_effective_vis ( def_id, vis, module_id, tag) ;
103- } ;
91+ }
10492 }
10593 }
10694 }
10795
108- // fn init_crate_effective_vis(&mut self) {
109-
110- // }
111-
11296 fn update_effective_vis (
11397 & mut self ,
11498 current_id : LocalDefId ,
@@ -117,20 +101,15 @@ impl<'r, 'a> AccessLevelsVisitor<'r, 'a> {
117101 tag : AccessLevel ,
118102 ) {
119103 if let Some ( inherited_effective_vis) = self . r . access_levels . get_effective_vis ( module_id) {
120- println ! ( "tag: {:?}" , tag) ;
121- println ! ( "inherited effective vis: {:?}" , inherited_effective_vis) ;
122104 let mut current_effective_vis = self . r . access_levels . get_effective_vis ( current_id) . copied ( ) . unwrap_or_default ( ) ;
123105 let nearest_available_vis = inherited_effective_vis. nearest_available ( tag) . unwrap ( ) ;
124- println ! ( "nearest available vis: {:?}" , nearest_available_vis) ;
125106 let calculated_effective_vis = match current_vis {
126107 Visibility :: Public => nearest_available_vis,
127108 Visibility :: Restricted ( _) => {
128109 if current_vis. is_at_least ( nearest_available_vis, & * self . r ) { nearest_available_vis} else { current_vis}
129110 }
130111 } ;
131- println ! ( "calculated effective vis: {:?}" , calculated_effective_vis) ;
132112 current_effective_vis. update ( calculated_effective_vis, tag, & * self . r ) ;
133- println ! ( "updated effective vis: {:?}" , current_effective_vis) ;
134113 self . r . access_levels . set_effective_vis ( current_id, current_effective_vis) ;
135114 }
136115 }
0 commit comments