@@ -58,7 +58,7 @@ pub struct ImportDirective {
5858 pub subclass : ImportDirectiveSubclass ,
5959 pub span : Span ,
6060 pub id : NodeId ,
61- pub is_public : bool , // see note in ImportResolution about how to use this
61+ pub is_public : bool , // see note in ImportResolutionPerNamespace about how to use this
6262 pub shadowable : Shadowable ,
6363}
6464
@@ -103,25 +103,25 @@ impl Target {
103103}
104104
105105#[ derive( Debug ) ]
106- /// An ImportResolution records what we know about an imported name.
106+ /// An ImportResolutionPerNamespace records what we know about an imported name.
107107/// More specifically, it records the number of unresolved `use` directives that import the name,
108108/// and for each namespace, it records the `use` directive importing the name in the namespace
109109/// and the `Target` to which the name in the namespace resolves (if applicable).
110110/// Different `use` directives may import the same name in different namespaces.
111- pub struct ImportResolution {
111+ pub struct ImportResolutionPerNamespace {
112112 // When outstanding_references reaches zero, outside modules can count on the targets being
113113 // correct. Before then, all bets are off; future `use` directives could override the name.
114114 // Since shadowing is forbidden, the only way outstanding_references > 1 in a legal program
115115 // is if the name is imported by exactly two `use` directives, one of which resolves to a
116116 // value and the other of which resolves to a type.
117117 pub outstanding_references : usize ,
118- pub type_ns : NsImportResolution ,
119- pub value_ns : NsImportResolution ,
118+ pub type_ns : ImportResolution ,
119+ pub value_ns : ImportResolution ,
120120}
121121
122- /// Records what we know about an imported name in a namespace (see `ImportResolution `).
122+ /// Records what we know about an imported name in a namespace (see `ImportResolutionPerNamespace `).
123123#[ derive( Clone , Debug ) ]
124- pub struct NsImportResolution {
124+ pub struct ImportResolution {
125125 /// Whether the name in the namespace was imported with a `use` or a `pub use`.
126126 pub is_public : bool ,
127127
@@ -132,23 +132,23 @@ pub struct NsImportResolution {
132132 pub id : NodeId ,
133133}
134134
135- impl :: std:: ops:: Index < Namespace > for ImportResolution {
136- type Output = NsImportResolution ;
137- fn index ( & self , ns : Namespace ) -> & NsImportResolution {
135+ impl :: std:: ops:: Index < Namespace > for ImportResolutionPerNamespace {
136+ type Output = ImportResolution ;
137+ fn index ( & self , ns : Namespace ) -> & ImportResolution {
138138 match ns { TypeNS => & self . type_ns , ValueNS => & self . value_ns }
139139 }
140140}
141141
142- impl :: std:: ops:: IndexMut < Namespace > for ImportResolution {
143- fn index_mut ( & mut self , ns : Namespace ) -> & mut NsImportResolution {
142+ impl :: std:: ops:: IndexMut < Namespace > for ImportResolutionPerNamespace {
143+ fn index_mut ( & mut self , ns : Namespace ) -> & mut ImportResolution {
144144 match ns { TypeNS => & mut self . type_ns , ValueNS => & mut self . value_ns }
145145 }
146146}
147147
148- impl ImportResolution {
149- pub fn new ( id : NodeId , is_public : bool ) -> ImportResolution {
150- let resolution = NsImportResolution { id : id, is_public : is_public, target : None } ;
151- ImportResolution {
148+ impl ImportResolutionPerNamespace {
149+ pub fn new ( id : NodeId , is_public : bool ) -> Self {
150+ let resolution = ImportResolution { id : id, is_public : is_public, target : None } ;
151+ ImportResolutionPerNamespace {
152152 outstanding_references : 0 , type_ns : resolution. clone ( ) , value_ns : resolution,
153153 }
154154 }
@@ -504,7 +504,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
504504 Some ( import_resolution) if import_resolution. outstanding_references == 0 => {
505505
506506 fn get_binding ( this : & mut Resolver ,
507- import_resolution : & ImportResolution ,
507+ import_resolution : & ImportResolutionPerNamespace ,
508508 namespace : Namespace ,
509509 source : Name )
510510 -> NamespaceResult {
@@ -644,7 +644,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
644644 directive. span ,
645645 target) ;
646646
647- import_resolution[ namespace] = NsImportResolution {
647+ import_resolution[ namespace] = ImportResolution {
648648 target : Some ( Target :: new ( target_module. clone ( ) ,
649649 name_binding. clone ( ) ,
650650 directive. shadowable ) ) ,
@@ -777,7 +777,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
777777 // Here we merge two import resolutions.
778778 let mut import_resolutions = module_. import_resolutions . borrow_mut ( ) ;
779779 let mut dest_import_resolution = import_resolutions. entry ( * name) . or_insert_with ( || {
780- ImportResolution :: new ( id, is_public)
780+ ImportResolutionPerNamespace :: new ( id, is_public)
781781 } ) ;
782782
783783 for & ns in [ TypeNS , ValueNS ] . iter ( ) {
@@ -787,7 +787,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
787787 import_directive. span ,
788788 * name,
789789 ns) ;
790- dest_import_resolution[ ns] = NsImportResolution {
790+ dest_import_resolution[ ns] = ImportResolution {
791791 id : id, is_public : is_public, target : Some ( target. clone ( ) )
792792 } ;
793793 }
@@ -832,10 +832,9 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
832832 let is_public = import_directive. is_public ;
833833
834834 let mut import_resolutions = module_. import_resolutions . borrow_mut ( ) ;
835- let dest_import_resolution = import_resolutions. entry ( name)
836- . or_insert_with ( || {
837- ImportResolution :: new ( id, is_public)
838- } ) ;
835+ let dest_import_resolution = import_resolutions. entry ( name) . or_insert_with ( || {
836+ ImportResolutionPerNamespace :: new ( id, is_public)
837+ } ) ;
839838
840839 debug ! ( "(resolving glob import) writing resolution `{}` in `{}` to `{}`" ,
841840 name,
@@ -864,7 +863,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
864863 "{}" ,
865864 msg) ;
866865 } else {
867- dest_import_resolution[ namespace] = NsImportResolution {
866+ dest_import_resolution[ namespace] = ImportResolution {
868867 target : Some ( Target :: new ( containing_module. clone ( ) ,
869868 name_bindings[ namespace] . clone ( ) ,
870869 import_directive. shadowable ) ) ,
@@ -886,7 +885,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
886885
887886 /// Checks that imported names and items don't have the same name.
888887 fn check_for_conflicting_import ( & mut self ,
889- import_resolution : & ImportResolution ,
888+ import_resolution : & ImportResolutionPerNamespace ,
890889 import_span : Span ,
891890 name : Name ,
892891 namespace : Namespace ) {
@@ -939,14 +938,14 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
939938 /// Checks that imported names and items don't have the same name.
940939 fn check_for_conflicts_between_imports_and_items ( & mut self ,
941940 module : & Module ,
942- import_resolution : & ImportResolution ,
941+ import : & ImportResolutionPerNamespace ,
943942 import_span : Span ,
944943 name : Name ) {
945944 // First, check for conflicts between imports and `extern crate`s.
946945 if module. external_module_children
947946 . borrow ( )
948947 . contains_key ( & name) {
949- match import_resolution . type_ns . target {
948+ match import . type_ns . target {
950949 Some ( ref target) if target. shadowable != Shadowable :: Always => {
951950 let msg = format ! ( "import `{0}` conflicts with imported crate in this module \
952951 (maybe you meant `use {0}::*`?)",
@@ -967,7 +966,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
967966 Some ( ref name_bindings) => ( * name_bindings) . clone ( ) ,
968967 } ;
969968
970- match import_resolution . value_ns . target {
969+ match import . value_ns . target {
971970 Some ( ref target) if target. shadowable != Shadowable :: Always => {
972971 if let Some ( ref value) = * name_bindings. value_ns . borrow ( ) {
973972 span_err ! ( self . resolver. session,
@@ -983,7 +982,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
983982 Some ( _) | None => { }
984983 }
985984
986- match import_resolution . type_ns . target {
985+ match import . type_ns . target {
987986 Some ( ref target) if target. shadowable != Shadowable :: Always => {
988987 if let Some ( ref ty) = * name_bindings. type_ns . borrow ( ) {
989988 let ( what, note) = match ty. module ( ) {
0 commit comments