13
13
//! Here we build the "reduced graph": the graph of the module tree without
14
14
//! any imports resolved.
15
15
16
- use DefModifiers ;
17
16
use resolve_imports:: ImportDirectiveSubclass :: { self , GlobImport } ;
18
17
use Module ;
19
18
use Namespace :: { self , TypeNS , ValueNS } ;
@@ -53,10 +52,9 @@ impl<'a> ToNameBinding<'a> for (Module<'a>, Span) {
53
52
}
54
53
}
55
54
56
- impl < ' a > ToNameBinding < ' a > for ( Def , Span , DefModifiers , ty:: Visibility ) {
55
+ impl < ' a > ToNameBinding < ' a > for ( Def , Span , ty:: Visibility ) {
57
56
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 }
60
58
}
61
59
}
62
60
@@ -136,7 +134,6 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
136
134
let parent = * parent_ref;
137
135
let name = item. name ;
138
136
let sp = item. span ;
139
- let modifiers = DefModifiers :: IMPORTABLE ;
140
137
self . current_module = parent;
141
138
let vis = self . resolve_visibility ( & item. vis ) ;
142
139
@@ -284,21 +281,21 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
284
281
ItemStatic ( _, m, _) => {
285
282
let mutbl = m == hir:: MutMutable ;
286
283
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) ) ;
288
285
}
289
286
ItemConst ( _, _) => {
290
287
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) ) ;
292
289
}
293
290
ItemFn ( _, _, _, _, _, _) => {
294
291
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) ) ;
296
293
}
297
294
298
295
// These items live in the type namespace.
299
296
ItemTy ( ..) => {
300
297
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) ) ;
302
299
}
303
300
304
301
ItemEnum ( ref enum_definition, _) => {
@@ -317,13 +314,13 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
317
314
ItemStruct ( ref struct_def, _) => {
318
315
// Define a name in the type namespace.
319
316
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) ) ;
321
318
322
319
// If this is a newtype or unit-like struct, define a name
323
320
// in the value namespace as well
324
321
if !struct_def. is_struct ( ) {
325
322
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) ) ;
327
324
}
328
325
329
326
// Record the def ID and fields of this struct.
@@ -355,8 +352,7 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
355
352
hir:: TypeTraitItem ( ..) => ( Def :: AssociatedTy ( def_id, item_def_id) , TypeNS ) ,
356
353
} ;
357
354
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) ) ;
360
356
361
357
self . trait_item_map . insert ( ( item. name , def_id) , item_def_id) ;
362
358
}
@@ -379,19 +375,16 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
379
375
380
376
// Variants are always treated as importable to allow them to be glob used.
381
377
// All variants are defined in both type and value namespaces as future-proofing.
382
- let modifiers = DefModifiers :: IMPORTABLE ;
383
378
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 ) ) ;
387
381
}
388
382
389
383
/// Constructs the reduced graph for one foreign item.
390
384
fn build_reduced_graph_for_foreign_item ( & mut self ,
391
385
foreign_item : & ForeignItem ,
392
386
parent : Module < ' b > ) {
393
387
let name = foreign_item. name ;
394
- let modifiers = DefModifiers :: IMPORTABLE ;
395
388
396
389
let def = match foreign_item. node {
397
390
ForeignItemFn ( ..) => {
@@ -403,7 +396,7 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
403
396
} ;
404
397
self . current_module = parent;
405
398
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) ) ;
407
400
}
408
401
409
402
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> {
438
431
439
432
let name = xcdef. name ;
440
433
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
- } ;
445
434
446
435
match def {
447
436
Def :: Mod ( _) | Def :: ForeignMod ( _) | Def :: Enum ( ..) => {
@@ -455,9 +444,8 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
455
444
debug ! ( "(building reduced graph for external crate) building variant {}" , name) ;
456
445
// Variants are always treated as importable to allow them to be glob used.
457
446
// 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) ) ;
461
449
if self . session . cstore . variant_kind ( variant_id) == Some ( VariantKind :: Struct ) {
462
450
// Not adding fields for variants as they are not accessed with a self receiver
463
451
self . structs . insert ( variant_id, Vec :: new ( ) ) ;
@@ -470,7 +458,7 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
470
458
Def :: Method ( ..) => {
471
459
debug ! ( "(building reduced graph for external crate) building value (fn/static) {}" ,
472
460
name) ;
473
- self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , modifiers , vis) ) ;
461
+ self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , vis) ) ;
474
462
}
475
463
Def :: Trait ( def_id) => {
476
464
debug ! ( "(building reduced graph for external crate) building type {}" , name) ;
@@ -496,16 +484,16 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
496
484
}
497
485
Def :: TyAlias ( ..) | Def :: AssociatedTy ( ..) => {
498
486
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) ) ;
500
488
}
501
489
Def :: Struct ( def_id)
502
490
if self . session . cstore . tuple_struct_definition_if_ctor ( def_id) . is_none ( ) => {
503
491
debug ! ( "(building reduced graph for external crate) building type and value for {}" ,
504
492
name) ;
505
- self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , modifiers , vis) ) ;
493
+ self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , vis) ) ;
506
494
if let Some ( ctor_def_id) = self . session . cstore . struct_ctor_def_id ( def_id) {
507
495
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) ) ;
509
497
}
510
498
511
499
// Record the def ID and fields of this struct.
0 commit comments