Skip to content

Commit 8988c45

Browse files
committed
Refactor away resolve_import_for_module
1 parent 43dffc3 commit 8988c45

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/librustc_resolve/resolve_imports.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
397397
::std::mem::swap(&mut imports, &mut unresolved_imports);
398398

399399
for import_directive in imports {
400-
match self.resolve_import_for_module(&import_directive) {
400+
match self.resolve_import(&import_directive) {
401401
Failed(err) => {
402402
let (span, help) = match err {
403403
Some((span, msg)) => (span, format!(". {}", msg)),
@@ -411,7 +411,11 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
411411
});
412412
}
413413
Indeterminate => unresolved_imports.push(import_directive),
414-
Success(()) => {}
414+
Success(()) => {
415+
// Decrement the count of unresolved imports.
416+
assert!(self.resolver.unresolved_imports >= 1);
417+
self.resolver.unresolved_imports -= 1;
418+
}
415419
}
416420
}
417421
}
@@ -421,25 +425,19 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
421425
/// don't know whether the name exists at the moment due to other
422426
/// currently-unresolved imports, or success if we know the name exists.
423427
/// If successful, the resolved bindings are written into the module.
424-
fn resolve_import_for_module(&mut self, directive: &'b ImportDirective) -> ResolveResult<()> {
428+
fn resolve_import(&mut self, directive: &'b ImportDirective) -> ResolveResult<()> {
425429
debug!("(resolving import for module) resolving import `{}::...` in `{}`",
426430
names_to_string(&directive.module_path),
427431
module_to_string(self.resolver.current_module));
428432

429-
self.resolver
430-
.resolve_module_path(&directive.module_path, DontUseLexicalScope, directive.span)
431-
// Once we have the module that contains the target, we can resolve the import.
432-
.and_then(|containing_module| self.resolve_import(containing_module, directive))
433-
.and_then(|()| {
434-
// Decrement the count of unresolved imports.
435-
assert!(self.resolver.unresolved_imports >= 1);
436-
self.resolver.unresolved_imports -= 1;
437-
Success(())
438-
})
439-
}
433+
let target_module = match self.resolver.resolve_module_path(&directive.module_path,
434+
DontUseLexicalScope,
435+
directive.span) {
436+
Success(module) => module,
437+
Indeterminate => return Indeterminate,
438+
Failed(err) => return Failed(err),
439+
};
440440

441-
fn resolve_import(&mut self, target_module: Module<'b>, directive: &'b ImportDirective)
442-
-> ResolveResult<()> {
443441
let (source, target, value_determined, type_determined) = match directive.subclass {
444442
SingleImport { source, target, ref value_determined, ref type_determined } =>
445443
(source, target, value_determined, type_determined),

0 commit comments

Comments
 (0)