@@ -25,7 +25,6 @@ use {names_to_string, module_to_string};
25
25
use ParentLink :: { self , ModuleParentLink , BlockParentLink } ;
26
26
use Resolver ;
27
27
use resolve_imports:: Shadowable ;
28
- use TypeNsDef ;
29
28
use { resolve_error, ResolutionError } ;
30
29
31
30
use self :: DuplicateCheckingMode :: * ;
@@ -130,7 +129,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
130
129
duplicate_checking_mode : DuplicateCheckingMode ,
131
130
// For printing errors
132
131
sp : Span )
133
- -> Rc < NameBindings > {
132
+ -> NameBindings {
134
133
// If this is the immediate descendant of a module, then we add the
135
134
// child name directly. Otherwise, we create or reuse an anonymous
136
135
// module and add the child to that.
@@ -141,7 +140,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
141
140
let child = parent. children . borrow ( ) . get ( & name) . cloned ( ) ;
142
141
match child {
143
142
None => {
144
- let child = Rc :: new ( NameBindings :: new ( ) ) ;
143
+ let child = NameBindings :: new ( ) ;
145
144
parent. children . borrow_mut ( ) . insert ( name, child. clone ( ) ) ;
146
145
child
147
146
}
@@ -173,27 +172,27 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
173
172
Some ( TypeNS )
174
173
}
175
174
ForbidDuplicateTypesAndModules => {
176
- if child. defined_in_namespace ( TypeNS ) {
175
+ if child. type_ns . defined ( ) {
177
176
duplicate_type = TypeError ;
178
177
}
179
178
Some ( TypeNS )
180
179
}
181
180
ForbidDuplicateValues => {
182
- if child. defined_in_namespace ( ValueNS ) {
181
+ if child. value_ns . defined ( ) {
183
182
duplicate_type = ValueError ;
184
183
}
185
184
Some ( ValueNS )
186
185
}
187
186
ForbidDuplicateTypesAndValues => {
188
187
let mut n = None ;
189
- match child. def_for_namespace ( TypeNS ) {
188
+ match child. type_ns . def ( ) {
190
189
Some ( DefMod ( _) ) | None => { }
191
190
Some ( _) => {
192
191
n = Some ( TypeNS ) ;
193
192
duplicate_type = TypeError ;
194
193
}
195
194
}
196
- if child. defined_in_namespace ( ValueNS ) {
195
+ if child. value_ns . defined ( ) {
197
196
duplicate_type = ValueError ;
198
197
n = Some ( ValueNS ) ;
199
198
}
@@ -213,7 +212,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
213
212
name)
214
213
) ;
215
214
{
216
- let r = child. span_for_namespace ( ns ) ;
215
+ let r = child[ ns ] . span ( ) ;
217
216
if let Some ( sp) = r {
218
217
self . session . span_note ( sp,
219
218
& format ! ( "first definition of {} `{}` here" ,
@@ -415,7 +414,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
415
414
let child = parent. children . borrow ( ) . get ( & name) . cloned ( ) ;
416
415
if let Some ( child) = child {
417
416
// check if there's struct of the same name already defined
418
- if child. defined_in_namespace ( TypeNS ) &&
417
+ if child. type_ns . defined ( ) &&
419
418
child. get_module_if_available ( ) . is_none ( ) {
420
419
self . session . span_warn ( sp,
421
420
& format ! ( "duplicate definition of {} `{}`. \
@@ -424,7 +423,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
424
423
namespace_error_to_string( TypeError ) ,
425
424
name) ) ;
426
425
{
427
- let r = child. span_for_namespace ( TypeNS ) ;
426
+ let r = child. type_ns . span ( ) ;
428
427
if let Some ( sp) = r {
429
428
self . session . span_note ( sp,
430
429
& format ! ( "first definition of {} `{}` here" ,
@@ -530,7 +529,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
530
529
let child = parent. children . borrow ( ) . get ( & name) . cloned ( ) ;
531
530
if let Some ( child) = child {
532
531
// check if theres a DefMod
533
- if let Some ( DefMod ( _) ) = child. def_for_namespace ( TypeNS ) {
532
+ if let Some ( DefMod ( _) ) = child. type_ns . def ( ) {
534
533
self . session . span_warn ( sp,
535
534
& format ! ( "duplicate definition of {} `{}`. \
536
535
Defining a module and a struct \
@@ -539,7 +538,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
539
538
namespace_error_to_string( TypeError ) ,
540
539
name) ) ;
541
540
{
542
- let r = child. span_for_namespace ( TypeNS ) ;
541
+ let r = child. type_ns . span ( ) ;
543
542
if let Some ( sp) = r {
544
543
self . session
545
544
. span_note ( sp,
@@ -752,26 +751,21 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
752
751
DefForeignMod ( def_id) |
753
752
DefStruct ( def_id) |
754
753
DefTy ( def_id, _) => {
755
- let type_def = child_name_bindings. type_def . borrow ( ) . clone ( ) ;
756
- match type_def {
757
- Some ( TypeNsDef { module_def : Some ( module_def) , .. } ) => {
758
- debug ! ( "(building reduced graph for external crate) already created \
759
- module") ;
760
- module_def. def_id . set ( Some ( def_id) ) ;
761
- }
762
- Some ( _) | None => {
763
- debug ! ( "(building reduced graph for external crate) building module {} {}" ,
764
- final_ident,
765
- is_public) ;
766
- let parent_link = self . get_parent_link ( new_parent, name) ;
767
-
768
- child_name_bindings. define_module ( parent_link,
769
- Some ( def_id) ,
770
- kind,
771
- true ,
772
- is_public,
773
- DUMMY_SP ) ;
774
- }
754
+ if let Some ( module_def) = child_name_bindings. type_ns . module ( ) {
755
+ debug ! ( "(building reduced graph for external crate) already created module" ) ;
756
+ module_def. def_id . set ( Some ( def_id) ) ;
757
+ } else {
758
+ debug ! ( "(building reduced graph for external crate) building module {} {}" ,
759
+ final_ident,
760
+ is_public) ;
761
+ let parent_link = self . get_parent_link ( new_parent, name) ;
762
+
763
+ child_name_bindings. define_module ( parent_link,
764
+ Some ( def_id) ,
765
+ kind,
766
+ true ,
767
+ is_public,
768
+ DUMMY_SP ) ;
775
769
}
776
770
}
777
771
_ => { }
@@ -807,7 +801,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
807
801
final_ident) ;
808
802
// impl methods have already been defined with the correct importability
809
803
// modifier
810
- let mut modifiers = match * child_name_bindings. value_def . borrow ( ) {
804
+ let mut modifiers = match * child_name_bindings. value_ns . borrow ( ) {
811
805
Some ( ref def) => ( modifiers & !DefModifiers :: IMPORTABLE ) |
812
806
( def. modifiers & DefModifiers :: IMPORTABLE ) ,
813
807
None => modifiers,
@@ -922,7 +916,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
922
916
923
917
self . handle_external_def ( def,
924
918
def_visibility,
925
- & * child_name_bindings,
919
+ & child_name_bindings,
926
920
& name. as_str ( ) ,
927
921
name,
928
922
root) ;
0 commit comments