about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/effective_visibilities.rs
diff options
context:
space:
mode:
authorbohan <bohan-zhang@foxmail.com>2023-08-31 00:43:13 +0800
committerbohan <bohan-zhang@foxmail.com>2023-08-31 20:00:04 +0800
commit107152141b384a51769f0c7957d6083506ea17e1 (patch)
tree89632a1256e796eb5ca385846665af4696c49bd0 /compiler/rustc_resolve/src/effective_visibilities.rs
parent2bd81316f24c74fefd0064bdc3fad6bbba86adb9 (diff)
downloadrust-107152141b384a51769f0c7957d6083506ea17e1.tar.gz
rust-107152141b384a51769f0c7957d6083506ea17e1.zip
fix(resolve): update def if binding is warning ambiguity
Diffstat (limited to 'compiler/rustc_resolve/src/effective_visibilities.rs')
-rw-r--r--compiler/rustc_resolve/src/effective_visibilities.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/rustc_resolve/src/effective_visibilities.rs b/compiler/rustc_resolve/src/effective_visibilities.rs
index eb210532f51..46f5df5ca6f 100644
--- a/compiler/rustc_resolve/src/effective_visibilities.rs
+++ b/compiler/rustc_resolve/src/effective_visibilities.rs
@@ -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
                 // 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 is_ambiguity =
+                    |binding: NameBinding<'a>, warn: bool| binding.ambiguity.is_some() && !warn;
                 let mut parent_id = ParentId::Def(module_id);
+                let mut warn_ambiguity = binding.warn_ambiguity;
                 while let NameBindingKind::Import { binding: nested_binding, .. } = binding.kind {
                     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
                         // be reexported because the root ambiguity blocks any access to them.
                         // (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);
                     binding = nested_binding;
+                    warn_ambiguity |= nested_binding.warn_ambiguity;
                 }
-
-                if binding.ambiguity.is_none()
+                if !is_ambiguity(binding, warn_ambiguity)
                     && 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);
                 }