effvis: Merge two similar code paths
This commit is contained in:
parent
4695ddf510
commit
ede21e8932
1 changed files with 22 additions and 33 deletions
|
@ -125,30 +125,15 @@ impl<'r, 'a, 'tcx> EffectiveVisibilitiesVisitor<'r, 'a, 'tcx> {
|
||||||
|
|
||||||
for (_, name_resolution) in resolutions.borrow().iter() {
|
for (_, name_resolution) in resolutions.borrow().iter() {
|
||||||
if let Some(mut binding) = name_resolution.borrow().binding() {
|
if let Some(mut binding) = name_resolution.borrow().binding() {
|
||||||
if !binding.is_ambiguity() {
|
|
||||||
// Set the given effective visibility level to `Level::Direct` and
|
// Set the given effective visibility level to `Level::Direct` and
|
||||||
// sets the rest of the `use` chain to `Level::Reexported` until
|
// sets the rest of the `use` chain to `Level::Reexported` until
|
||||||
// we hit the actual exported item.
|
// we hit the actual exported item.
|
||||||
|
//
|
||||||
|
// If the binding is ambiguous, put the root ambiguity binding and all reexports
|
||||||
|
// leading to it into the table. They are used by the `ambiguous_glob_reexports`
|
||||||
|
// lint. For all bindings added to the table this way `is_ambiguity` returns true.
|
||||||
let mut parent_id = ParentId::Def(module_id);
|
let mut parent_id = ParentId::Def(module_id);
|
||||||
while let NameBindingKind::Import { binding: nested_binding, .. } = binding.kind
|
while let NameBindingKind::Import { binding: nested_binding, .. } = binding.kind {
|
||||||
{
|
|
||||||
let binding_id = ImportId::new_unchecked(binding);
|
|
||||||
self.update_import(binding_id, parent_id);
|
|
||||||
|
|
||||||
parent_id = ParentId::Import(binding_id);
|
|
||||||
binding = nested_binding;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(def_id) = binding.res().opt_def_id().and_then(|id| id.as_local()) {
|
|
||||||
self.update_def(def_id, binding.vis.expect_local(), parent_id);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Put the root ambiguity binding and all reexports leading to it into the
|
|
||||||
// table. They are used by the `ambiguous_glob_reexports` lint. For all
|
|
||||||
// bindings added to the table here `is_ambiguity` returns true.
|
|
||||||
let mut parent_id = ParentId::Def(module_id);
|
|
||||||
while let NameBindingKind::Import { binding: nested_binding, .. } = binding.kind
|
|
||||||
{
|
|
||||||
let binding_id = ImportId::new_unchecked(binding);
|
let binding_id = ImportId::new_unchecked(binding);
|
||||||
self.update_import(binding_id, parent_id);
|
self.update_import(binding_id, parent_id);
|
||||||
|
|
||||||
|
@ -162,6 +147,10 @@ impl<'r, 'a, 'tcx> EffectiveVisibilitiesVisitor<'r, 'a, 'tcx> {
|
||||||
parent_id = ParentId::Import(binding_id);
|
parent_id = ParentId::Import(binding_id);
|
||||||
binding = nested_binding;
|
binding = nested_binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if binding.ambiguity.is_none()
|
||||||
|
&& let Some(def_id) = binding.res().opt_def_id().and_then(|id| id.as_local()) {
|
||||||
|
self.update_def(def_id, binding.vis.expect_local(), parent_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue