about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-01-31 00:38:45 +0000
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-02-03 23:39:14 +0000
commit0c4062175994d28120da4aa7518e3e10b19e2db3 (patch)
tree79803ca17c57f40a545f7c5a080cced5699a7630
parent23bdbb13f4087751d7310ae896ccd3e1ae690abb (diff)
downloadrust-0c4062175994d28120da4aa7518e3e10b19e2db3.tar.gz
rust-0c4062175994d28120da4aa7518e3e10b19e2db3.zip
Refactor away resolve_module_in_lexical_scope
-rw-r--r--src/librustc_resolve/lib.rs45
1 files changed, 11 insertions, 34 deletions
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 3198c31da81..761365122ef 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -1387,16 +1387,22 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                         // This is not a crate-relative path. We resolve the
                         // first component of the path in the current lexical
                         // scope and then proceed to resolve below that.
-                        match self.resolve_module_in_lexical_scope(module_, module_path[0]) {
+                        match self.resolve_item_in_lexical_scope(module_,
+                                                                 module_path[0],
+                                                                 TypeNS,
+                                                                 true) {
                             Failed(err) => return Failed(err),
                             Indeterminate => {
                                 debug!("(resolving module path for import) indeterminate; bailing");
                                 return Indeterminate;
                             }
-                            Success(containing_module) => {
-                                search_module = containing_module;
-                                start_index = 1;
-                                last_private = LastMod(AllPublic);
+                            Success((target, _)) => match target.binding.module() {
+                                Some(containing_module) => {
+                                    search_module = containing_module;
+                                    start_index = 1;
+                                    last_private = LastMod(AllPublic);
+                                }
+                                None => return Failed(None),
                             }
                         }
                     }
@@ -1477,35 +1483,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
         }
     }
 
-    /// Resolves a module name in the current lexical scope.
-    fn resolve_module_in_lexical_scope(&mut self,
-                                       module_: Module<'a>,
-                                       name: Name)
-                                       -> ResolveResult<Module<'a>> {
-        // If this module is an anonymous module, resolve the item in the
-        // lexical scope. Otherwise, resolve the item from the crate root.
-        let resolve_result = self.resolve_item_in_lexical_scope(module_, name, TypeNS, true);
-        match resolve_result {
-            Success((target, _)) => {
-                if let Some(module_def) = target.binding.module() {
-                    return Success(module_def)
-                } else {
-                    debug!("!!! (resolving module in lexical scope) module \
-                            wasn't actually a module!");
-                    return Failed(None);
-                }
-            }
-            Indeterminate => {
-                debug!("(resolving module in lexical scope) indeterminate; bailing");
-                return Indeterminate;
-            }
-            Failed(err) => {
-                debug!("(resolving module in lexical scope) failed to resolve");
-                return Failed(err);
-            }
-        }
-    }
-
     /// Returns the nearest normal module parent of the given module.
     fn get_nearest_normal_module_parent(&mut self, module_: Module<'a>) -> Option<Module<'a>> {
         let mut module_ = module_;