about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-03-13 02:53:22 +0000
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-03-26 18:23:53 +0000
commit8988c4538e30bce6985cc0b8458521d9a4a87277 (patch)
treea379bf284124e8f9c582671fcb1f371051fa4b96
parent43dffc329402d99a93e224bba1a30f587c70dc7d (diff)
downloadrust-8988c4538e30bce6985cc0b8458521d9a4a87277.tar.gz
rust-8988c4538e30bce6985cc0b8458521d9a4a87277.zip
Refactor away `resolve_import_for_module`
-rw-r--r--src/librustc_resolve/resolve_imports.rs30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs
index 769033e11cc..b6fbfe17406 100644
--- a/src/librustc_resolve/resolve_imports.rs
+++ b/src/librustc_resolve/resolve_imports.rs
@@ -397,7 +397,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
         ::std::mem::swap(&mut imports, &mut unresolved_imports);
 
         for import_directive in imports {
-            match self.resolve_import_for_module(&import_directive) {
+            match self.resolve_import(&import_directive) {
                 Failed(err) => {
                     let (span, help) = match err {
                         Some((span, msg)) => (span, format!(". {}", msg)),
@@ -411,7 +411,11 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
                     });
                 }
                 Indeterminate => unresolved_imports.push(import_directive),
-                Success(()) => {}
+                Success(()) => {
+                    // Decrement the count of unresolved imports.
+                    assert!(self.resolver.unresolved_imports >= 1);
+                    self.resolver.unresolved_imports -= 1;
+                }
             }
         }
     }
@@ -421,25 +425,19 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
     /// don't know whether the name exists at the moment due to other
     /// currently-unresolved imports, or success if we know the name exists.
     /// If successful, the resolved bindings are written into the module.
-    fn resolve_import_for_module(&mut self, directive: &'b ImportDirective) -> ResolveResult<()> {
+    fn resolve_import(&mut self, directive: &'b ImportDirective) -> ResolveResult<()> {
         debug!("(resolving import for module) resolving import `{}::...` in `{}`",
                names_to_string(&directive.module_path),
                module_to_string(self.resolver.current_module));
 
-        self.resolver
-            .resolve_module_path(&directive.module_path, DontUseLexicalScope, directive.span)
-            // Once we have the module that contains the target, we can resolve the import.
-            .and_then(|containing_module| self.resolve_import(containing_module, directive))
-            .and_then(|()| {
-                // Decrement the count of unresolved imports.
-                assert!(self.resolver.unresolved_imports >= 1);
-                self.resolver.unresolved_imports -= 1;
-                Success(())
-            })
-    }
+        let target_module = match self.resolver.resolve_module_path(&directive.module_path,
+                                                                    DontUseLexicalScope,
+                                                                    directive.span) {
+            Success(module) => module,
+            Indeterminate => return Indeterminate,
+            Failed(err) => return Failed(err),
+        };
 
-    fn resolve_import(&mut self, target_module: Module<'b>, directive: &'b ImportDirective)
-                      -> ResolveResult<()> {
         let (source, target, value_determined, type_determined) = match directive.subclass {
             SingleImport { source, target, ref value_determined, ref type_determined } =>
                 (source, target, value_determined, type_determined),