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
@@ -136,7 +134,6 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
136134 let parent = * parent_ref;
137135 let name = item. name ;
138136 let sp = item. span ;
139- let modifiers = DefModifiers :: IMPORTABLE ;
140137 self . current_module = parent;
141138 let vis = self . resolve_visibility ( & item. vis ) ;
142139
@@ -284,21 +281,21 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
284281 ItemStatic ( _, m, _) => {
285282 let mutbl = m == hir:: MutMutable ;
286283 let def = Def :: Static ( self . ast_map . local_def_id ( item. id ) , mutbl) ;
287- self . define ( parent, name, ValueNS , ( def, sp, modifiers , vis) ) ;
284+ self . define ( parent, name, ValueNS , ( def, sp, vis) ) ;
288285 }
289286 ItemConst ( _, _) => {
290287 let def = Def :: Const ( self . ast_map . local_def_id ( item. id ) ) ;
291- self . define ( parent, name, ValueNS , ( def, sp, modifiers , vis) ) ;
288+ self . define ( parent, name, ValueNS , ( def, sp, vis) ) ;
292289 }
293290 ItemFn ( _, _, _, _, _, _) => {
294291 let def = Def :: Fn ( self . ast_map . local_def_id ( item. id ) ) ;
295- self . define ( parent, name, ValueNS , ( def, sp, modifiers , vis) ) ;
292+ self . define ( parent, name, ValueNS , ( def, sp, vis) ) ;
296293 }
297294
298295 // These items live in the type namespace.
299296 ItemTy ( ..) => {
300297 let def = Def :: TyAlias ( self . ast_map . local_def_id ( item. id ) ) ;
301- self . define ( parent, name, TypeNS , ( def, sp, modifiers , vis) ) ;
298+ self . define ( parent, name, TypeNS , ( def, sp, vis) ) ;
302299 }
303300
304301 ItemEnum ( ref enum_definition, _) => {
@@ -317,13 +314,13 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
317314 ItemStruct ( ref struct_def, _) => {
318315 // Define a name in the type namespace.
319316 let def = Def :: Struct ( self . ast_map . local_def_id ( item. id ) ) ;
320- self . define ( parent, name, TypeNS , ( def, sp, modifiers , vis) ) ;
317+ self . define ( parent, name, TypeNS , ( def, sp, vis) ) ;
321318
322319 // If this is a newtype or unit-like struct, define a name
323320 // in the value namespace as well
324321 if !struct_def. is_struct ( ) {
325322 let def = Def :: Struct ( self . ast_map . local_def_id ( struct_def. id ( ) ) ) ;
326- self . define ( parent, name, ValueNS , ( def, sp, modifiers , vis) ) ;
323+ self . define ( parent, name, ValueNS , ( def, sp, vis) ) ;
327324 }
328325
329326 // Record the def ID and fields of this struct.
@@ -355,8 +352,7 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
355352 hir:: TypeTraitItem ( ..) => ( Def :: AssociatedTy ( def_id, item_def_id) , TypeNS ) ,
356353 } ;
357354
358- let modifiers = DefModifiers :: empty ( ) ; // NB: not DefModifiers::IMPORTABLE
359- self . define ( module_parent, item. name , ns, ( def, item. span , modifiers, vis) ) ;
355+ self . define ( module_parent, item. name , ns, ( def, item. span , vis) ) ;
360356
361357 self . trait_item_map . insert ( ( item. name , def_id) , item_def_id) ;
362358 }
@@ -379,19 +375,16 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
379375
380376 // Variants are always treated as importable to allow them to be glob used.
381377 // All variants are defined in both type and value namespaces as future-proofing.
382- let modifiers = DefModifiers :: IMPORTABLE ;
383378 let def = Def :: Variant ( item_id, self . ast_map . local_def_id ( variant. node . data . id ( ) ) ) ;
384-
385- self . define ( parent, name, ValueNS , ( def, variant. span , modifiers, parent. vis ) ) ;
386- self . define ( parent, name, TypeNS , ( def, variant. span , modifiers, parent. vis ) ) ;
379+ self . define ( parent, name, ValueNS , ( def, variant. span , parent. vis ) ) ;
380+ self . define ( parent, name, TypeNS , ( def, variant. span , parent. vis ) ) ;
387381 }
388382
389383 /// Constructs the reduced graph for one foreign item.
390384 fn build_reduced_graph_for_foreign_item ( & mut self ,
391385 foreign_item : & ForeignItem ,
392386 parent : Module < ' b > ) {
393387 let name = foreign_item. name ;
394- let modifiers = DefModifiers :: IMPORTABLE ;
395388
396389 let def = match foreign_item. node {
397390 ForeignItemFn ( ..) => {
@@ -403,7 +396,7 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
403396 } ;
404397 self . current_module = parent;
405398 let vis = self . resolve_visibility ( & foreign_item. vis ) ;
406- self . define ( parent, name, ValueNS , ( def, foreign_item. span , modifiers , vis) ) ;
399+ self . define ( parent, name, ValueNS , ( def, foreign_item. span , vis) ) ;
407400 }
408401
409402 fn build_reduced_graph_for_block ( & mut self , block : & Block , parent : & mut Module < ' b > ) {
@@ -438,10 +431,6 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
438431
439432 let name = xcdef. name ;
440433 let vis = if parent. is_trait ( ) { ty:: Visibility :: Public } else { xcdef. vis } ;
441- let modifiers = match parent. is_normal ( ) {
442- true => DefModifiers :: IMPORTABLE ,
443- false => DefModifiers :: empty ( ) ,
444- } ;
445434
446435 match def {
447436 Def :: Mod ( _) | Def :: ForeignMod ( _) | Def :: Enum ( ..) => {
@@ -455,9 +444,8 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
455444 debug ! ( "(building reduced graph for external crate) building variant {}" , name) ;
456445 // Variants are always treated as importable to allow them to be glob used.
457446 // All variants are defined in both type and value namespaces as future-proofing.
458- let modifiers = DefModifiers :: IMPORTABLE ;
459- self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , modifiers, vis) ) ;
460- self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , modifiers, vis) ) ;
447+ self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , vis) ) ;
448+ self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , vis) ) ;
461449 if self . session . cstore . variant_kind ( variant_id) == Some ( VariantKind :: Struct ) {
462450 // Not adding fields for variants as they are not accessed with a self receiver
463451 self . structs . insert ( variant_id, Vec :: new ( ) ) ;
@@ -470,7 +458,7 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
470458 Def :: Method ( ..) => {
471459 debug ! ( "(building reduced graph for external crate) building value (fn/static) {}" ,
472460 name) ;
473- self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , modifiers , vis) ) ;
461+ self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , vis) ) ;
474462 }
475463 Def :: Trait ( def_id) => {
476464 debug ! ( "(building reduced graph for external crate) building type {}" , name) ;
@@ -496,16 +484,16 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
496484 }
497485 Def :: TyAlias ( ..) | Def :: AssociatedTy ( ..) => {
498486 debug ! ( "(building reduced graph for external crate) building type {}" , name) ;
499- self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , modifiers , vis) ) ;
487+ self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , vis) ) ;
500488 }
501489 Def :: Struct ( def_id)
502490 if self . session . cstore . tuple_struct_definition_if_ctor ( def_id) . is_none ( ) => {
503491 debug ! ( "(building reduced graph for external crate) building type and value for {}" ,
504492 name) ;
505- self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , modifiers , vis) ) ;
493+ self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , vis) ) ;
506494 if let Some ( ctor_def_id) = self . session . cstore . struct_ctor_def_id ( def_id) {
507495 let def = Def :: Struct ( ctor_def_id) ;
508- self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , modifiers , vis) ) ;
496+ self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , vis) ) ;
509497 }
510498
511499 // Record the def ID and fields of this struct.
0 commit comments