diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 796e0f5518a0cc0c569afae6611e48c575c2d612..691114574d0a92cdd9d26c3879bad9aaf70f6f9d 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -203,24 +203,6 @@ fn try_result(&self, ns: Namespace, allow_private_imports: bool) self.binding.map(Success) } - - fn report_conflicts(&self, mut report: F) { - let binding = match self.binding { - Some(binding) => binding, - None => return, - }; - - for duplicate_glob in self.duplicate_globs.iter() { - // FIXME #31337: We currently allow items to shadow glob-imported re-exports. - if !binding.is_import() { - if let NameBindingKind::Import { binding, .. } = duplicate_glob.kind { - if binding.is_import() { continue } - } - } - - report(duplicate_glob, binding); - } - } } impl<'a> ::ModuleS<'a> { @@ -677,15 +659,23 @@ fn finalize_resolutions_in(&mut self, module: Module<'b>, report_unresolved_impo let mut reexports = Vec::new(); for (&(name, ns), resolution) in module.resolutions.borrow().iter() { let resolution = resolution.borrow(); - resolution.report_conflicts(|b1, b2| { - self.report_conflict(module, name, ns, b1, b2) - }); - let binding = match resolution.binding { Some(binding) => binding, None => continue, }; + // Report conflicts + for duplicate_glob in resolution.duplicate_globs.iter() { + // FIXME #31337: We currently allow items to shadow glob-imported re-exports. + if !binding.is_import() { + if let NameBindingKind::Import { binding, .. } = duplicate_glob.kind { + if binding.is_import() { continue } + } + } + + self.report_conflict(module, name, ns, duplicate_glob, binding); + } + if binding.vis == ty::Visibility::Public && (binding.is_import() || binding.is_extern_crate()) { if let Some(def) = binding.def() {