@@ -69,7 +69,6 @@ impl<'r, 'a> AccessLevelsVisitor<'r, 'a> {
69
69
let resolutions = self . r . resolutions ( module) ;
70
70
71
71
for ( .., name_resolution) in resolutions. borrow ( ) . iter ( ) {
72
-
73
72
if let Some ( binding) = name_resolution. borrow ( ) . binding ( ) {
74
73
let tag = match binding. is_import ( ) {
75
74
true => {
@@ -101,16 +100,24 @@ impl<'r, 'a> AccessLevelsVisitor<'r, 'a> {
101
100
) {
102
101
if let Some ( inherited_effective_vis) = self . r . access_levels . get_effective_vis ( module_id) {
103
102
let mut current_effective_vis = self . r . access_levels . get_effective_vis ( current_id) . copied ( ) . unwrap_or_default ( ) ;
104
- let nearest_available_vis = inherited_effective_vis. nearest_available ( tag) . unwrap ( ) ;
105
- let calculated_effective_vis = match current_vis {
106
- Visibility :: Public => nearest_available_vis,
107
- Visibility :: Restricted ( _) => {
108
- if current_vis. is_at_least ( nearest_available_vis, & * self . r ) { nearest_available_vis} else { current_vis}
109
- }
110
- } ;
111
103
let current_effective_vis_copy = current_effective_vis. clone ( ) ;
112
- current_effective_vis. update ( calculated_effective_vis, tag, & * self . r ) ;
113
-
104
+ for level in [
105
+ AccessLevel :: Public ,
106
+ AccessLevel :: Exported ,
107
+ AccessLevel :: Reachable ,
108
+ AccessLevel :: ReachableFromImplTrait ,
109
+ ] {
110
+ if level <= tag {
111
+ let nearest_available_vis = inherited_effective_vis. nearest_available ( level) . unwrap ( ) ;
112
+ let calculated_effective_vis = match current_vis {
113
+ Visibility :: Public => nearest_available_vis,
114
+ Visibility :: Restricted ( _) => {
115
+ if current_vis. is_at_least ( nearest_available_vis, & * self . r ) { nearest_available_vis} else { current_vis}
116
+ }
117
+ } ;
118
+ current_effective_vis. update ( calculated_effective_vis, level, & * self . r ) ;
119
+ }
120
+ }
114
121
if current_effective_vis_copy != current_effective_vis {
115
122
self . changed = true ;
116
123
self . r . access_levels . set_effective_vis ( current_id, current_effective_vis) ;
0 commit comments