1313//! Here we build the "reduced graph": the graph of the module tree without
1414//! any imports resolved.
1515
16- use DefModifiers ;
1716use resolve_imports:: ImportDirectiveSubclass :: { self , GlobImport } ;
1817use Module ;
1918use Namespace :: { self , TypeNS , ValueNS } ;
@@ -53,10 +52,9 @@ impl<'a> ToNameBinding<'a> for (Module<'a>, Span) {
5352 }
5453}
5554
56- impl < ' a > ToNameBinding < ' a > for ( Def , Span , DefModifiers , ty:: Visibility ) {
55+ impl < ' a > ToNameBinding < ' a > for ( Def , Span , ty:: Visibility ) {
5756 fn to_name_binding ( self ) -> NameBinding < ' a > {
58- let kind = NameBindingKind :: Def ( self . 0 ) ;
59- NameBinding { modifiers : self . 2 , kind : kind, span : Some ( self . 1 ) , vis : self . 3 }
57+ NameBinding { kind : NameBindingKind :: Def ( self . 0 ) , span : Some ( self . 1 ) , vis : self . 2 }
6058 }
6159}
6260
@@ -105,7 +103,6 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
105103 let parent = * parent_ref;
106104 let name = item. name ;
107105 let sp = item. span ;
108- let modifiers = DefModifiers :: IMPORTABLE ;
109106 self . current_module = parent;
110107 let vis = self . resolve_visibility ( & item. vis ) ;
111108
@@ -268,21 +265,21 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
268265 ItemStatic ( _, m, _) => {
269266 let mutbl = m == hir:: MutMutable ;
270267 let def = Def :: Static ( self . ast_map . local_def_id ( item. id ) , mutbl) ;
271- self . define ( parent, name, ValueNS , ( def, sp, modifiers , vis) ) ;
268+ self . define ( parent, name, ValueNS , ( def, sp, vis) ) ;
272269 }
273270 ItemConst ( _, _) => {
274271 let def = Def :: Const ( self . ast_map . local_def_id ( item. id ) ) ;
275- self . define ( parent, name, ValueNS , ( def, sp, modifiers , vis) ) ;
272+ self . define ( parent, name, ValueNS , ( def, sp, vis) ) ;
276273 }
277274 ItemFn ( _, _, _, _, _, _) => {
278275 let def = Def :: Fn ( self . ast_map . local_def_id ( item. id ) ) ;
279- self . define ( parent, name, ValueNS , ( def, sp, modifiers , vis) ) ;
276+ self . define ( parent, name, ValueNS , ( def, sp, vis) ) ;
280277 }
281278
282279 // These items live in the type namespace.
283280 ItemTy ( ..) => {
284281 let def = Def :: TyAlias ( self . ast_map . local_def_id ( item. id ) ) ;
285- self . define ( parent, name, TypeNS , ( def, sp, modifiers , vis) ) ;
282+ self . define ( parent, name, TypeNS , ( def, sp, vis) ) ;
286283 }
287284
288285 ItemEnum ( ref enum_definition, _) => {
@@ -301,13 +298,13 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
301298 ItemStruct ( ref struct_def, _) => {
302299 // Define a name in the type namespace.
303300 let def = Def :: Struct ( self . ast_map . local_def_id ( item. id ) ) ;
304- self . define ( parent, name, TypeNS , ( def, sp, modifiers , vis) ) ;
301+ self . define ( parent, name, TypeNS , ( def, sp, vis) ) ;
305302
306303 // If this is a newtype or unit-like struct, define a name
307304 // in the value namespace as well
308305 if !struct_def. is_struct ( ) {
309306 let def = Def :: Struct ( self . ast_map . local_def_id ( struct_def. id ( ) ) ) ;
310- self . define ( parent, name, ValueNS , ( def, sp, modifiers , vis) ) ;
307+ self . define ( parent, name, ValueNS , ( def, sp, vis) ) ;
311308 }
312309
313310 // Record the def ID and fields of this struct.
@@ -339,8 +336,7 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
339336 hir:: TypeTraitItem ( ..) => ( Def :: AssociatedTy ( def_id, item_def_id) , TypeNS ) ,
340337 } ;
341338
342- let modifiers = DefModifiers :: empty ( ) ; // NB: not DefModifiers::IMPORTABLE
343- self . define ( module_parent, item. name , ns, ( def, item. span , modifiers, vis) ) ;
339+ self . define ( module_parent, item. name , ns, ( def, item. span , vis) ) ;
344340
345341 self . trait_item_map . insert ( ( item. name , def_id) , item_def_id) ;
346342 }
@@ -363,19 +359,16 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
363359
364360 // Variants are always treated as importable to allow them to be glob used.
365361 // All variants are defined in both type and value namespaces as future-proofing.
366- let modifiers = DefModifiers :: IMPORTABLE ;
367362 let def = Def :: Variant ( item_id, self . ast_map . local_def_id ( variant. node . data . id ( ) ) ) ;
368-
369- self . define ( parent, name, ValueNS , ( def, variant. span , modifiers, parent. vis ) ) ;
370- self . define ( parent, name, TypeNS , ( def, variant. span , modifiers, parent. vis ) ) ;
363+ self . define ( parent, name, ValueNS , ( def, variant. span , parent. vis ) ) ;
364+ self . define ( parent, name, TypeNS , ( def, variant. span , parent. vis ) ) ;
371365 }
372366
373367 /// Constructs the reduced graph for one foreign item.
374368 fn build_reduced_graph_for_foreign_item ( & mut self ,
375369 foreign_item : & ForeignItem ,
376370 parent : Module < ' b > ) {
377371 let name = foreign_item. name ;
378- let modifiers = DefModifiers :: IMPORTABLE ;
379372
380373 let def = match foreign_item. node {
381374 ForeignItemFn ( ..) => {
@@ -387,7 +380,7 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
387380 } ;
388381 self . current_module = parent;
389382 let vis = self . resolve_visibility ( & foreign_item. vis ) ;
390- self . define ( parent, name, ValueNS , ( def, foreign_item. span , modifiers , vis) ) ;
383+ self . define ( parent, name, ValueNS , ( def, foreign_item. span , vis) ) ;
391384 }
392385
393386 fn build_reduced_graph_for_block ( & mut self , block : & Block , parent : & mut Module < ' b > ) {
@@ -422,10 +415,6 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
422415
423416 let name = xcdef. name ;
424417 let vis = if parent. is_trait ( ) { ty:: Visibility :: Public } else { xcdef. vis } ;
425- let modifiers = match parent. is_normal ( ) {
426- true => DefModifiers :: IMPORTABLE ,
427- false => DefModifiers :: empty ( ) ,
428- } ;
429418
430419 match def {
431420 Def :: Mod ( _) | Def :: ForeignMod ( _) | Def :: Enum ( ..) => {
@@ -439,9 +428,8 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
439428 debug ! ( "(building reduced graph for external crate) building variant {}" , name) ;
440429 // Variants are always treated as importable to allow them to be glob used.
441430 // All variants are defined in both type and value namespaces as future-proofing.
442- let modifiers = DefModifiers :: IMPORTABLE ;
443- self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , modifiers, vis) ) ;
444- self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , modifiers, vis) ) ;
431+ self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , vis) ) ;
432+ self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , vis) ) ;
445433 if self . session . cstore . variant_kind ( variant_id) == Some ( VariantKind :: Struct ) {
446434 // Not adding fields for variants as they are not accessed with a self receiver
447435 self . structs . insert ( variant_id, Vec :: new ( ) ) ;
@@ -454,7 +442,7 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
454442 Def :: Method ( ..) => {
455443 debug ! ( "(building reduced graph for external crate) building value (fn/static) {}" ,
456444 name) ;
457- self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , modifiers , vis) ) ;
445+ self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , vis) ) ;
458446 }
459447 Def :: Trait ( def_id) => {
460448 debug ! ( "(building reduced graph for external crate) building type {}" , name) ;
@@ -480,16 +468,16 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
480468 }
481469 Def :: TyAlias ( ..) | Def :: AssociatedTy ( ..) => {
482470 debug ! ( "(building reduced graph for external crate) building type {}" , name) ;
483- self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , modifiers , vis) ) ;
471+ self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , vis) ) ;
484472 }
485473 Def :: Struct ( def_id)
486474 if self . session . cstore . tuple_struct_definition_if_ctor ( def_id) . is_none ( ) => {
487475 debug ! ( "(building reduced graph for external crate) building type and value for {}" ,
488476 name) ;
489- self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , modifiers , vis) ) ;
477+ self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , vis) ) ;
490478 if let Some ( ctor_def_id) = self . session . cstore . struct_ctor_def_id ( def_id) {
491479 let def = Def :: Struct ( ctor_def_id) ;
492- self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , modifiers , vis) ) ;
480+ self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , vis) ) ;
493481 }
494482
495483 // Record the def ID and fields of this struct.
0 commit comments