@@ -29,7 +29,6 @@ use syntax::attr::AttrMetaMethods;
29
29
use syntax:: codemap:: Span ;
30
30
use syntax:: util:: lev_distance:: find_best_match_for_name;
31
31
32
- use std:: mem:: replace;
33
32
use std:: cell:: { Cell , RefCell } ;
34
33
35
34
/// Contains data for specific types of import directives.
@@ -371,11 +370,17 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
371
370
i,
372
371
self . resolver. unresolved_imports) ;
373
372
374
- self . resolve_imports_for_module_subtree ( self . resolver . graph_root , & mut errors) ;
373
+ // Attempt to resolve imports in all local modules.
374
+ for module in self . resolver . arenas . local_modules ( ) . iter ( ) {
375
+ self . resolver . current_module = module;
376
+ self . resolve_imports_in_current_module ( & mut errors) ;
377
+ }
375
378
376
379
if self . resolver . unresolved_imports == 0 {
377
380
debug ! ( "(resolving imports) success" ) ;
378
- self . finalize_resolutions ( self . resolver . graph_root , false ) ;
381
+ for module in self . resolver . arenas . local_modules ( ) . iter ( ) {
382
+ self . finalize_resolutions_in ( module, false ) ;
383
+ }
379
384
break ;
380
385
}
381
386
@@ -385,7 +390,9 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
385
390
// to avoid generating multiple errors on the same import.
386
391
// Imports that are still indeterminate at this point are actually blocked
387
392
// by errored imports, so there is no point reporting them.
388
- self . finalize_resolutions ( self . resolver . graph_root , errors. len ( ) == 0 ) ;
393
+ for module in self . resolver . arenas . local_modules ( ) . iter ( ) {
394
+ self . finalize_resolutions_in ( module, errors. len ( ) == 0 ) ;
395
+ }
389
396
for e in errors {
390
397
self . import_resolving_error ( e)
391
398
}
@@ -422,22 +429,6 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
422
429
ResolutionError :: UnresolvedImport ( Some ( ( & path, & e. help ) ) ) ) ;
423
430
}
424
431
425
- /// Attempts to resolve imports for the given module and all of its
426
- /// submodules.
427
- fn resolve_imports_for_module_subtree ( & mut self ,
428
- module_ : Module < ' b > ,
429
- errors : & mut Vec < ImportResolvingError < ' b > > ) {
430
- debug ! ( "(resolving imports for module subtree) resolving {}" ,
431
- module_to_string( & module_) ) ;
432
- let orig_module = replace ( & mut self . resolver . current_module , module_) ;
433
- self . resolve_imports_in_current_module ( errors) ;
434
- self . resolver . current_module = orig_module;
435
-
436
- for ( _, child_module) in module_. module_children . borrow ( ) . iter ( ) {
437
- self . resolve_imports_for_module_subtree ( child_module, errors) ;
438
- }
439
- }
440
-
441
432
/// Attempts to resolve imports for the given module only.
442
433
fn resolve_imports_in_current_module ( & mut self , errors : & mut Vec < ImportResolvingError < ' b > > ) {
443
434
let mut imports = Vec :: new ( ) ;
@@ -675,7 +666,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
675
666
676
667
// Miscellaneous post-processing, including recording reexports, recording shadowed traits,
677
668
// reporting conflicts, reporting the PRIVATE_IN_PUBLIC lint, and reporting unresolved imports.
678
- fn finalize_resolutions ( & mut self , module : Module < ' b > , report_unresolved_imports : bool ) {
669
+ fn finalize_resolutions_in ( & mut self , module : Module < ' b > , report_unresolved_imports : bool ) {
679
670
// Since import resolution is finished, globs will not define any more names.
680
671
* module. globs . borrow_mut ( ) = Vec :: new ( ) ;
681
672
@@ -723,10 +714,6 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
723
714
break ;
724
715
}
725
716
}
726
-
727
- for ( _, child) in module. module_children . borrow ( ) . iter ( ) {
728
- self . finalize_resolutions ( child, report_unresolved_imports) ;
729
- }
730
717
}
731
718
}
732
719
0 commit comments