Skip to content

Commit 51ca449

Browse files
committed
Refactor away define
1 parent 20b99d3 commit 51ca449

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/librustc_resolve/resolve_imports.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,11 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
502502
None
503503
};
504504

505-
self.define(module_, target, ns, directive.import(binding, privacy_error));
505+
let imported_binding = directive.import(binding, privacy_error);
506+
let conflict = module_.try_define_child(target, ns, imported_binding);
507+
if let Err(old_binding) = conflict {
508+
self.report_conflict(target, ns, &directive.import(binding, None), old_binding);
509+
}
506510
}
507511
module_.decrement_outstanding_references_for(target, ns);
508512
}
@@ -613,7 +617,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
613617
for (&(name, ns), resolution) in target_module.resolutions.borrow().iter() {
614618
if let Some(Success(binding)) = resolution.try_result() {
615619
if binding.defined_with(DefModifiers::IMPORTABLE | DefModifiers::PUBLIC) {
616-
self.define(module_, name, ns, directive.import(binding, None));
620+
let _ = module_.try_define_child(name, ns, directive.import(binding, None));
617621
}
618622
}
619623
}
@@ -631,16 +635,6 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
631635
return Success(());
632636
}
633637

634-
fn define(&mut self,
635-
parent: Module<'b>,
636-
name: Name,
637-
ns: Namespace,
638-
binding: NameBinding<'b>) {
639-
if let Err(old_binding) = parent.try_define_child(name, ns, binding.clone()) {
640-
self.report_conflict(name, ns, &binding, old_binding);
641-
}
642-
}
643-
644638
fn report_conflict(&mut self,
645639
name: Name,
646640
ns: Namespace,

0 commit comments

Comments
 (0)