mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
fix(resolve): update def if binding is warning ambiguity
This commit is contained in:
parent
2bd81316f2
commit
107152141b
@ -128,11 +128,14 @@ impl<'r, 'a, 'tcx> EffectiveVisibilitiesVisitor<'r, 'a, 'tcx> {
|
|||||||
// If the binding is ambiguous, put the root ambiguity binding and all reexports
|
// 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`
|
// 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.
|
// lint. For all bindings added to the table this way `is_ambiguity` returns true.
|
||||||
|
let is_ambiguity =
|
||||||
|
|binding: NameBinding<'a>, warn: bool| binding.ambiguity.is_some() && !warn;
|
||||||
let mut parent_id = ParentId::Def(module_id);
|
let mut parent_id = ParentId::Def(module_id);
|
||||||
|
let mut warn_ambiguity = binding.warn_ambiguity;
|
||||||
while let NameBindingKind::Import { binding: nested_binding, .. } = binding.kind {
|
while let NameBindingKind::Import { binding: nested_binding, .. } = binding.kind {
|
||||||
self.update_import(binding, parent_id);
|
self.update_import(binding, parent_id);
|
||||||
|
|
||||||
if binding.ambiguity.is_some() {
|
if is_ambiguity(binding, warn_ambiguity) {
|
||||||
// Stop at the root ambiguity, further bindings in the chain should not
|
// Stop at the root ambiguity, further bindings in the chain should not
|
||||||
// be reexported because the root ambiguity blocks any access to them.
|
// be reexported because the root ambiguity blocks any access to them.
|
||||||
// (Those further bindings are most likely not ambiguities themselves.)
|
// (Those further bindings are most likely not ambiguities themselves.)
|
||||||
@ -141,9 +144,9 @@ impl<'r, 'a, 'tcx> EffectiveVisibilitiesVisitor<'r, 'a, 'tcx> {
|
|||||||
|
|
||||||
parent_id = ParentId::Import(binding);
|
parent_id = ParentId::Import(binding);
|
||||||
binding = nested_binding;
|
binding = nested_binding;
|
||||||
|
warn_ambiguity |= nested_binding.warn_ambiguity;
|
||||||
}
|
}
|
||||||
|
if !is_ambiguity(binding, warn_ambiguity)
|
||||||
if binding.ambiguity.is_none()
|
|
||||||
&& let Some(def_id) = binding.res().opt_def_id().and_then(|id| id.as_local()) {
|
&& 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);
|
self.update_def(def_id, binding.vis.expect_local(), parent_id);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// check-pass
|
// build-pass
|
||||||
// aux-build: ../ambiguous-4-extern.rs
|
// aux-build: ../ambiguous-4-extern.rs
|
||||||
|
|
||||||
extern crate ambiguous_4_extern;
|
extern crate ambiguous_4_extern;
|
||||||
|
Loading…
Reference in New Issue
Block a user