Skip to content

Commit

Permalink
Refactor away resolve_module_in_lexical_scope
Browse files Browse the repository at this point in the history
  • Loading branch information
jseyfried committed Feb 3, 2016
1 parent 23bdbb1 commit 0c40621
Showing 1 changed file with 11 additions and 34 deletions.
45 changes: 11 additions & 34 deletions src/librustc_resolve/lib.rs
Expand Up @@ -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),
}
}
}
Expand Down Expand Up @@ -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_;
Expand Down

0 comments on commit 0c40621

Please sign in to comment.