提交 5868e78b 编写于 作者: J Jeffrey Seyfried

Refactor away `resolution.report_conflicts()`.

上级 79e82b5c
......@@ -203,24 +203,6 @@ fn try_result(&self, ns: Namespace, allow_private_imports: bool)
self.binding.map(Success)
}
fn report_conflicts<F: FnMut(&NameBinding, &NameBinding)>(&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() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册