Skip to content

Commit 5fe5036

Browse files
committed
fix update func
1 parent 2f81511 commit 5fe5036

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

compiler/rustc_resolve/src/access_levels.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ impl<'r, 'a> AccessLevelsVisitor<'r, 'a> {
6969
let resolutions = self.r.resolutions(module);
7070

7171
for (.., name_resolution) in resolutions.borrow().iter() {
72-
7372
if let Some(binding) = name_resolution.borrow().binding() {
7473
let tag = match binding.is_import() {
7574
true => {
@@ -101,16 +100,24 @@ impl<'r, 'a> AccessLevelsVisitor<'r, 'a> {
101100
) {
102101
if let Some(inherited_effective_vis) = self.r.access_levels.get_effective_vis(module_id) {
103102
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-
};
111103
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+
}
114121
if current_effective_vis_copy != current_effective_vis {
115122
self.changed = true;
116123
self.r.access_levels.set_effective_vis(current_id, current_effective_vis);

0 commit comments

Comments
 (0)