@@ -96,7 +96,7 @@ use std::mem::replace;
96
96
use std:: rc:: { Rc , Weak } ;
97
97
use std:: usize;
98
98
99
- use resolve_imports:: { Target , ImportDirective , ImportResolution } ;
99
+ use resolve_imports:: { Target , ImportDirective , ImportResolutionPerNamespace } ;
100
100
use resolve_imports:: Shadowable ;
101
101
102
102
// NB: This module needs to be declared first so diagnostics are
@@ -328,7 +328,7 @@ fn resolve_error<'b, 'a: 'b, 'tcx: 'a>(resolver: &'b Resolver<'a, 'tcx>,
328
328
. import_resolutions
329
329
. borrow ( )
330
330
. get ( & name) {
331
- let item = resolver. ast_map . expect_item ( directive. value_id ) ;
331
+ let item = resolver. ast_map . expect_item ( directive. value_ns . id ) ;
332
332
resolver. session . span_note ( item. span , "constant imported here" ) ;
333
333
}
334
334
}
@@ -793,7 +793,7 @@ pub struct Module {
793
793
anonymous_children : RefCell < NodeMap < Rc < Module > > > ,
794
794
795
795
// The status of resolving each import in this module.
796
- import_resolutions : RefCell < HashMap < Name , ImportResolution > > ,
796
+ import_resolutions : RefCell < HashMap < Name , ImportResolutionPerNamespace > > ,
797
797
798
798
// The number of unresolved globs that this module exports.
799
799
glob_count : Cell < usize > ,
@@ -912,7 +912,7 @@ bitflags! {
912
912
// Records a possibly-private value, type, or module definition.
913
913
#[ derive( Debug ) ]
914
914
struct NsDef {
915
- modifiers : DefModifiers , // see note in ImportResolution about how to use this
915
+ modifiers : DefModifiers , // see note in ImportResolutionPerNamespace about how to use this
916
916
def_or_module : DefOrModule ,
917
917
span : Option < Span > ,
918
918
}
@@ -1491,7 +1491,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1491
1491
// adjacent import statements are processed as though they mutated the
1492
1492
// current scope.
1493
1493
if let Some ( import_resolution) = module_. import_resolutions . borrow ( ) . get ( & name) {
1494
- match ( * import_resolution) . target_for_namespace ( namespace ) {
1494
+ match import_resolution[ namespace ] . target . clone ( ) {
1495
1495
None => {
1496
1496
// Not found; continue.
1497
1497
debug ! ( "(resolving item in lexical scope) found import resolution, but not \
@@ -1501,7 +1501,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1501
1501
Some ( target) => {
1502
1502
debug ! ( "(resolving item in lexical scope) using import resolution" ) ;
1503
1503
// track used imports and extern crates as well
1504
- let id = import_resolution. id ( namespace ) ;
1504
+ let id = import_resolution[ namespace ] . id ;
1505
1505
self . used_imports . insert ( ( id, namespace) ) ;
1506
1506
self . record_import_use ( id, name) ;
1507
1507
if let Some ( DefId { krate : kid, ..} ) = target. target_module . def_id ( ) {
@@ -1712,21 +1712,23 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1712
1712
1713
1713
// Check the list of resolved imports.
1714
1714
match module_. import_resolutions . borrow ( ) . get ( & name) {
1715
- Some ( import_resolution) if allow_private_imports || import_resolution. is_public => {
1715
+ Some ( import_resolution) if allow_private_imports ||
1716
+ import_resolution[ namespace] . is_public => {
1716
1717
1717
- if import_resolution. is_public && import_resolution. outstanding_references != 0 {
1718
+ if import_resolution[ namespace] . is_public &&
1719
+ import_resolution. outstanding_references != 0 {
1718
1720
debug ! ( "(resolving name in module) import unresolved; bailing out" ) ;
1719
1721
return Indeterminate ;
1720
1722
}
1721
- match import_resolution. target_for_namespace ( namespace ) {
1723
+ match import_resolution[ namespace ] . target . clone ( ) {
1722
1724
None => {
1723
1725
debug ! ( "(resolving name in module) name found, but not in namespace {:?}" ,
1724
1726
namespace) ;
1725
1727
}
1726
1728
Some ( target) => {
1727
1729
debug ! ( "(resolving name in module) resolved to import" ) ;
1728
1730
// track used imports and extern crates as well
1729
- let id = import_resolution. id ( namespace ) ;
1731
+ let id = import_resolution[ namespace ] . id ;
1730
1732
self . used_imports . insert ( ( id, namespace) ) ;
1731
1733
self . record_import_use ( id, name) ;
1732
1734
if let Some ( DefId { krate : kid, ..} ) = target. target_module . def_id ( ) {
@@ -3651,17 +3653,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3651
3653
3652
3654
// Look for imports.
3653
3655
for ( _, import) in search_module. import_resolutions . borrow ( ) . iter ( ) {
3654
- let target = match import. target_for_namespace ( TypeNS ) {
3656
+ let target = match import. type_ns . target {
3655
3657
None => continue ,
3656
- Some ( target) => target,
3658
+ Some ( ref target) => target,
3657
3659
} ;
3658
3660
let did = match target. binding . def ( ) {
3659
3661
Some ( DefTrait ( trait_def_id) ) => trait_def_id,
3660
3662
Some ( ..) | None => continue ,
3661
3663
} ;
3662
3664
if self . trait_item_map . contains_key ( & ( name, did) ) {
3663
3665
add_trait_info ( & mut found_traits, did, name) ;
3664
- let id = import. type_id ;
3666
+ let id = import. type_ns . id ;
3665
3667
self . used_imports . insert ( ( id, TypeNS ) ) ;
3666
3668
let trait_name = self . get_trait_name ( did) ;
3667
3669
self . record_import_use ( id, trait_name) ;
@@ -3734,7 +3736,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3734
3736
let import_resolutions = module_. import_resolutions . borrow ( ) ;
3735
3737
for ( & name, import_resolution) in import_resolutions. iter ( ) {
3736
3738
let value_repr;
3737
- match import_resolution. target_for_namespace ( ValueNS ) {
3739
+ match import_resolution. value_ns . target {
3738
3740
None => {
3739
3741
value_repr = "" . to_string ( ) ;
3740
3742
}
@@ -3745,7 +3747,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3745
3747
}
3746
3748
3747
3749
let type_repr;
3748
- match import_resolution. target_for_namespace ( TypeNS ) {
3750
+ match import_resolution. type_ns . target {
3749
3751
None => {
3750
3752
type_repr = "" . to_string ( ) ;
3751
3753
}
0 commit comments