@@ -125,43 +125,32 @@ impl<'r, 'a, 'tcx> EffectiveVisibilitiesVisitor<'r, 'a, 'tcx> {
125125
126126 for ( _, name_resolution) in resolutions. borrow ( ) . iter ( ) {
127127 if let Some ( mut binding) = name_resolution. borrow ( ) . binding ( ) {
128- if !binding. is_ambiguity ( ) {
129- // Set the given effective visibility level to `Level::Direct` and
130- // sets the rest of the `use` chain to `Level::Reexported` until
131- // we hit the actual exported item.
132- let mut parent_id = ParentId :: Def ( module_id) ;
133- while let NameBindingKind :: Import { binding : nested_binding, .. } = binding. kind
134- {
135- let binding_id = ImportId :: new_unchecked ( binding) ;
136- self . update_import ( binding_id, parent_id) ;
137-
138- parent_id = ParentId :: Import ( binding_id) ;
139- binding = nested_binding;
140- }
141-
142- if let Some ( def_id) = binding. res ( ) . opt_def_id ( ) . and_then ( |id| id. as_local ( ) ) {
143- self . update_def ( def_id, binding. vis . expect_local ( ) , parent_id) ;
128+ // Set the given effective visibility level to `Level::Direct` and
129+ // sets the rest of the `use` chain to `Level::Reexported` until
130+ // we hit the actual exported item.
131+ //
132+ // If the binding is ambiguous, put the root ambiguity binding and all reexports
133+ // leading to it into the table. They are used by the `ambiguous_glob_reexports`
134+ // lint. For all bindings added to the table this way `is_ambiguity` returns true.
135+ let mut parent_id = ParentId :: Def ( module_id) ;
136+ while let NameBindingKind :: Import { binding : nested_binding, .. } = binding. kind {
137+ let binding_id = ImportId :: new_unchecked ( binding) ;
138+ self . update_import ( binding_id, parent_id) ;
139+
140+ if binding. ambiguity . is_some ( ) {
141+ // Stop at the root ambiguity, further bindings in the chain should not
142+ // be reexported because the root ambiguity blocks any access to them.
143+ // (Those further bindings are most likely not ambiguities themselves.)
144+ break ;
144145 }
145- } else {
146- // Put the root ambiguity binding and all reexports leading to it into the
147- // table. They are used by the `ambiguous_glob_reexports` lint. For all
148- // bindings added to the table here `is_ambiguity` returns true.
149- let mut parent_id = ParentId :: Def ( module_id) ;
150- while let NameBindingKind :: Import { binding : nested_binding, .. } = binding. kind
151- {
152- let binding_id = ImportId :: new_unchecked ( binding) ;
153- self . update_import ( binding_id, parent_id) ;
154146
155- if binding. ambiguity . is_some ( ) {
156- // Stop at the root ambiguity, further bindings in the chain should not
157- // be reexported because the root ambiguity blocks any access to them.
158- // (Those further bindings are most likely not ambiguities themselves.)
159- break ;
160- }
147+ parent_id = ParentId :: Import ( binding_id) ;
148+ binding = nested_binding;
149+ }
161150
162- parent_id = ParentId :: Import ( binding_id ) ;
163- binding = nested_binding ;
164- }
151+ if binding . ambiguity . is_none ( )
152+ && let Some ( def_id ) = binding. res ( ) . opt_def_id ( ) . and_then ( |id| id . as_local ( ) ) {
153+ self . update_def ( def_id , binding . vis . expect_local ( ) , parent_id ) ;
165154 }
166155 }
167156 }
0 commit comments