about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2014-02-07 14:45:18 -0500
committerNiko Matsakis <niko@alum.mit.edu>2014-02-11 16:55:23 -0500
commitb2b4c79b179413d4a5e1d706844b11dfca8226c8 (patch)
tree61589c843a10b4e3138c949005fcac7705f517eb /src
parent949e1c7935776ddb3e67ade590e9df58a5894cf8 (diff)
resolve -- rewrite conflict closure into method
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/resolve.rs91
1 files changed, 50 insertions, 41 deletions
diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs
index a941c1318ca..9623f6f0cbc 100644
--- a/src/librustc/middle/resolve.rs
+++ b/src/librustc/middle/resolve.rs
@@ -2567,52 +2567,15 @@ impl Resolver {
             }
         }
 
-        let merge_import_resolution = |name, name_bindings: @NameBindings| {
-            let dest_import_resolution;
-            let mut import_resolutions = module_.import_resolutions
-                                                .borrow_mut();
-            match import_resolutions.get().find(&name) {
-                None => {
-                    // Create a new import resolution from this child.
-                    dest_import_resolution =
-                        @ImportResolution::new(id, is_public);
-                    import_resolutions.get().insert(name,
-                                                    dest_import_resolution);
-                }
-                Some(&existing_import_resolution) => {
-                    dest_import_resolution = existing_import_resolution;
-                }
-            }
-
-            debug!("(resolving glob import) writing resolution `{}` in `{}` \
-                    to `{}`",
-                   token::get_ident(name).get().to_str(),
-                   self.module_to_str(containing_module),
-                   self.module_to_str(module_));
-
-            // Merge the child item into the import resolution.
-            if name_bindings.defined_in_public_namespace(ValueNS) {
-                debug!("(resolving glob import) ... for value target");
-                dest_import_resolution.value_target.set(
-                    Some(Target::new(containing_module, name_bindings)));
-                dest_import_resolution.value_id.set(id);
-            }
-            if name_bindings.defined_in_public_namespace(TypeNS) {
-                debug!("(resolving glob import) ... for type target");
-                dest_import_resolution.type_target.set(
-                    Some(Target::new(containing_module, name_bindings)));
-                dest_import_resolution.type_id.set(id);
-            }
-            dest_import_resolution.is_public.set(is_public);
-        };
-
         // Add all children from the containing module.
         self.populate_module_if_necessary(containing_module);
 
         {
             let children = containing_module.children.borrow();
             for (&name, name_bindings) in children.get().iter() {
-                merge_import_resolution(name, *name_bindings);
+                self.merge_import_resolution(module_, containing_module,
+                                             id, is_public,
+                                             name, *name_bindings);
             }
         }
 
@@ -2623,7 +2586,9 @@ impl Resolver {
             for (&name, module) in external_module_children.get().iter() {
                 let name_bindings =
                     @Resolver::create_name_bindings_from_module(*module);
-                merge_import_resolution(name, name_bindings);
+                self.merge_import_resolution(module_, containing_module,
+                                             id, is_public,
+                                             name, name_bindings);
             }
         }
 
@@ -2641,6 +2606,50 @@ impl Resolver {
         return Success(());
     }
 
+    fn merge_import_resolution(&mut self,
+                               module_: @Module,
+                               containing_module: @Module,
+                               id: NodeId,
+                               is_public: bool,
+                               name: Name,
+                               name_bindings: @NameBindings) {
+        let dest_import_resolution;
+        let mut import_resolutions = module_.import_resolutions.borrow_mut();
+        match import_resolutions.get().find(&name) {
+            None => {
+                // Create a new import resolution from this child.
+                dest_import_resolution =
+                    @ImportResolution::new(id, is_public);
+                import_resolutions.get().insert(name,
+                                                dest_import_resolution);
+            }
+            Some(&existing_import_resolution) => {
+                dest_import_resolution = existing_import_resolution;
+            }
+        }
+
+        debug!("(resolving glob import) writing resolution `{}` in `{}` \
+               to `{}`",
+               token::get_ident(name).get().to_str(),
+               self.module_to_str(containing_module),
+               self.module_to_str(module_));
+
+        // Merge the child item into the import resolution.
+        if name_bindings.defined_in_public_namespace(ValueNS) {
+            debug!("(resolving glob import) ... for value target");
+            dest_import_resolution.value_target.set(
+                Some(Target::new(containing_module, name_bindings)));
+            dest_import_resolution.value_id.set(id);
+        }
+        if name_bindings.defined_in_public_namespace(TypeNS) {
+            debug!("(resolving glob import) ... for type target");
+            dest_import_resolution.type_target.set(
+                Some(Target::new(containing_module, name_bindings)));
+            dest_import_resolution.type_id.set(id);
+        }
+        dest_import_resolution.is_public.set(is_public);
+    }
+
     /// Resolves the given module path from the given root `module_`.
     fn resolve_module_path_from_root(&mut self,
                                      module_: @Module,