@@ -56,17 +56,31 @@ impl<'r, 'a> AccessLevelsVisitor<'r, 'a> {
56
56
if this. r . opt_local_def_id ( import. id ) . is_some ( ) {
57
57
let vis = match binding. vis {
58
58
Visibility :: Public => Visibility :: Public ,
59
- Visibility :: Restricted ( id) => Visibility :: Restricted ( id. expect_local ( ) )
59
+ Visibility :: Restricted ( id) => Visibility :: Restricted ( id. expect_local ( ) ) ,
60
60
} ;
61
- this. update_effective_vis ( this. r . local_def_id ( import. id ) , vis, parent_id, AccessLevel :: Exported ) ;
61
+ this. update_effective_vis (
62
+ this. r . local_def_id ( import. id ) ,
63
+ vis,
64
+ parent_id,
65
+ AccessLevel :: Exported ,
66
+ ) ;
62
67
if let ImportKind :: Single { additional_ids, .. } = import. kind {
63
-
64
68
if let Some ( id) = this. r . opt_local_def_id ( additional_ids. 0 ) {
65
- this. update_effective_vis ( id, vis, parent_id, AccessLevel :: Exported ) ;
69
+ this. update_effective_vis (
70
+ id,
71
+ vis,
72
+ parent_id,
73
+ AccessLevel :: Exported ,
74
+ ) ;
66
75
}
67
76
68
77
if let Some ( id) = this. r . opt_local_def_id ( additional_ids. 1 ) {
69
- this. update_effective_vis ( id, vis, parent_id, AccessLevel :: Exported ) ;
78
+ this. update_effective_vis (
79
+ id,
80
+ vis,
81
+ parent_id,
82
+ AccessLevel :: Exported ,
83
+ ) ;
70
84
}
71
85
}
72
86
@@ -76,8 +90,8 @@ impl<'r, 'a> AccessLevelsVisitor<'r, 'a> {
76
90
}
77
91
} ;
78
92
79
- let module = self . r . get_module ( module_id. to_def_id ( ) ) . unwrap ( ) ;
80
- let resolutions = self . r . resolutions ( module) ;
93
+ let module = self . r . get_module ( module_id. to_def_id ( ) ) . unwrap ( ) ;
94
+ let resolutions = self . r . resolutions ( module) ;
81
95
82
96
for ( .., name_resolution) in resolutions. borrow ( ) . iter ( ) {
83
97
if let Some ( binding) = name_resolution. borrow ( ) . binding ( ) {
@@ -87,8 +101,8 @@ impl<'r, 'a> AccessLevelsVisitor<'r, 'a> {
87
101
set_import_binding_access_level ( self , binding, module_id) ;
88
102
}
89
103
AccessLevel :: Exported
90
- } ,
91
- false => AccessLevel :: Public
104
+ }
105
+ false => AccessLevel :: Public ,
92
106
} ;
93
107
94
108
if let Some ( def_id) = binding. res ( ) . opt_def_id ( ) . and_then ( |id| id. as_local ( ) ) && !binding. is_ambiguity ( ) {
@@ -110,7 +124,8 @@ impl<'r, 'a> AccessLevelsVisitor<'r, 'a> {
110
124
tag : AccessLevel ,
111
125
) {
112
126
if let Some ( inherited_effective_vis) = self . r . access_levels . get_effective_vis ( module_id) {
113
- let mut current_effective_vis = self . r . access_levels . get_effective_vis ( current_id) . copied ( ) . unwrap_or_default ( ) ;
127
+ let mut current_effective_vis =
128
+ self . r . access_levels . get_effective_vis ( current_id) . copied ( ) . unwrap_or_default ( ) ;
114
129
let current_effective_vis_copy = current_effective_vis. clone ( ) ;
115
130
for level in [
116
131
AccessLevel :: Public ,
@@ -119,11 +134,16 @@ impl<'r, 'a> AccessLevelsVisitor<'r, 'a> {
119
134
AccessLevel :: ReachableFromImplTrait ,
120
135
] {
121
136
if level <= tag {
122
- let nearest_available_vis = inherited_effective_vis. nearest_available ( level) . unwrap ( ) ;
137
+ let nearest_available_vis =
138
+ inherited_effective_vis. nearest_available ( level) . unwrap ( ) ;
123
139
let calculated_effective_vis = match current_vis {
124
140
Visibility :: Public => nearest_available_vis,
125
141
Visibility :: Restricted ( _) => {
126
- if current_vis. is_at_least ( nearest_available_vis, & * self . r ) { nearest_available_vis} else { current_vis}
142
+ if current_vis. is_at_least ( nearest_available_vis, & * self . r ) {
143
+ nearest_available_vis
144
+ } else {
145
+ current_vis
146
+ }
127
147
}
128
148
} ;
129
149
current_effective_vis. update ( calculated_effective_vis, level, & * self . r ) ;
@@ -169,7 +189,12 @@ impl<'r, 'ast> Visitor<'ast> for AccessLevelsVisitor<'ast, 'r> {
169
189
// Foreign modules inherit level from parents.
170
190
ast:: ItemKind :: ForeignMod ( ..) => {
171
191
let parent_id = self . r . local_parent ( def_id) ;
172
- self . update_effective_vis ( def_id, Visibility :: Public , parent_id, AccessLevel :: Public ) ;
192
+ self . update_effective_vis (
193
+ def_id,
194
+ Visibility :: Public ,
195
+ parent_id,
196
+ AccessLevel :: Public ,
197
+ ) ;
173
198
}
174
199
175
200
// Only exported `macro_rules!` items are public, but they always are
0 commit comments