Skip to content

Commit 5868e78

Browse files
committed
Refactor away resolution.report_conflicts().
1 parent 79e82b5 commit 5868e78

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

src/librustc_resolve/resolve_imports.rs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -203,24 +203,6 @@ impl<'a> NameResolution<'a> {
203203

204204
self.binding.map(Success)
205205
}
206-
207-
fn report_conflicts<F: FnMut(&NameBinding, &NameBinding)>(&self, mut report: F) {
208-
let binding = match self.binding {
209-
Some(binding) => binding,
210-
None => return,
211-
};
212-
213-
for duplicate_glob in self.duplicate_globs.iter() {
214-
// FIXME #31337: We currently allow items to shadow glob-imported re-exports.
215-
if !binding.is_import() {
216-
if let NameBindingKind::Import { binding, .. } = duplicate_glob.kind {
217-
if binding.is_import() { continue }
218-
}
219-
}
220-
221-
report(duplicate_glob, binding);
222-
}
223-
}
224206
}
225207

226208
impl<'a> ::ModuleS<'a> {
@@ -677,15 +659,23 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
677659
let mut reexports = Vec::new();
678660
for (&(name, ns), resolution) in module.resolutions.borrow().iter() {
679661
let resolution = resolution.borrow();
680-
resolution.report_conflicts(|b1, b2| {
681-
self.report_conflict(module, name, ns, b1, b2)
682-
});
683-
684662
let binding = match resolution.binding {
685663
Some(binding) => binding,
686664
None => continue,
687665
};
688666

667+
// Report conflicts
668+
for duplicate_glob in resolution.duplicate_globs.iter() {
669+
// FIXME #31337: We currently allow items to shadow glob-imported re-exports.
670+
if !binding.is_import() {
671+
if let NameBindingKind::Import { binding, .. } = duplicate_glob.kind {
672+
if binding.is_import() { continue }
673+
}
674+
}
675+
676+
self.report_conflict(module, name, ns, duplicate_glob, binding);
677+
}
678+
689679
if binding.vis == ty::Visibility::Public &&
690680
(binding.is_import() || binding.is_extern_crate()) {
691681
if let Some(def) = binding.def() {

0 commit comments

Comments
 (0)