@@ -1423,47 +1423,29 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1423
1423
namespace,
1424
1424
module_to_string( & * module_) ) ;
1425
1425
1426
- // The current module node is handled specially. First, check for
1427
- // its immediate children.
1428
- build_reduced_graph:: populate_module_if_necessary ( self , & module_) ;
1429
-
1430
- if let Some ( binding) = module_. get_child ( name, namespace) {
1431
- debug ! ( "top name bindings succeeded" ) ;
1432
- return Success ( ( Target :: new ( module_, binding, Shadowable :: Never ) , false ) ) ;
1433
- }
1426
+ // Proceed up the scope chain looking for parent modules.
1427
+ let mut search_module = module_;
1428
+ loop {
1429
+ // Resolve the name in the parent module.
1430
+ match self . resolve_name_in_module ( search_module, name, namespace, true , record_used) {
1431
+ Failed ( Some ( ( span, msg) ) ) => {
1432
+ resolve_error ( self , span, ResolutionError :: FailedToResolve ( & * msg) ) ;
1433
+ }
1434
+ Failed ( None ) => ( ) , // Continue up the search chain.
1435
+ Indeterminate => {
1436
+ // We couldn't see through the higher scope because of an
1437
+ // unresolved import higher up. Bail.
1434
1438
1435
- // Now check for its import directives. We don't have to have resolved
1436
- // all its imports in the usual way; this is because chains of
1437
- // adjacent import statements are processed as though they mutated the
1438
- // current scope.
1439
- if let Some ( import_resolution) =
1440
- module_. import_resolutions . borrow ( ) . get ( & ( name, namespace) ) {
1441
- match import_resolution. target . clone ( ) {
1442
- None => {
1443
- // Not found; continue.
1444
- debug ! ( "(resolving item in lexical scope) found import resolution, but not \
1445
- in namespace {:?}",
1446
- namespace) ;
1439
+ debug ! ( "(resolving item in lexical scope) indeterminate higher scope; bailing" ) ;
1440
+ return Indeterminate ;
1447
1441
}
1448
- Some ( target) => {
1449
- debug ! ( "(resolving item in lexical scope) using import resolution" ) ;
1450
- // track used imports and extern crates as well
1451
- let id = import_resolution. id ;
1452
- if record_used {
1453
- self . used_imports . insert ( ( id, namespace) ) ;
1454
- self . record_import_use ( id, name) ;
1455
- if let Some ( DefId { krate : kid, ..} ) = target. target_module . def_id ( ) {
1456
- self . used_crates . insert ( kid) ;
1457
- }
1458
- }
1459
- return Success ( ( target, false ) ) ;
1442
+ Success ( ( target, used_reexport) ) => {
1443
+ // We found the module.
1444
+ debug ! ( "(resolving item in lexical scope) found name in module, done" ) ;
1445
+ return Success ( ( target, used_reexport) ) ;
1460
1446
}
1461
1447
}
1462
- }
1463
1448
1464
- // Finally, proceed up the scope chain looking for parent modules.
1465
- let mut search_module = module_;
1466
- loop {
1467
1449
// Go to the next parent.
1468
1450
match search_module. parent_link {
1469
1451
NoParentLink => {
@@ -1485,26 +1467,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1485
1467
search_module = parent_module_node;
1486
1468
}
1487
1469
}
1488
-
1489
- // Resolve the name in the parent module.
1490
- match self . resolve_name_in_module ( search_module, name, namespace, true , record_used) {
1491
- Failed ( Some ( ( span, msg) ) ) => {
1492
- resolve_error ( self , span, ResolutionError :: FailedToResolve ( & * msg) ) ;
1493
- }
1494
- Failed ( None ) => ( ) , // Continue up the search chain.
1495
- Indeterminate => {
1496
- // We couldn't see through the higher scope because of an
1497
- // unresolved import higher up. Bail.
1498
-
1499
- debug ! ( "(resolving item in lexical scope) indeterminate higher scope; bailing" ) ;
1500
- return Indeterminate ;
1501
- }
1502
- Success ( ( target, used_reexport) ) => {
1503
- // We found the module.
1504
- debug ! ( "(resolving item in lexical scope) found name in module, done" ) ;
1505
- return Success ( ( target, used_reexport) ) ;
1506
- }
1507
- }
1508
1470
}
1509
1471
}
1510
1472
0 commit comments