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
@@ -105,7 +103,6 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
105
103
let parent = * parent_ref;
106
104
let name = item. name ;
107
105
let sp = item. span ;
108
- let modifiers = DefModifiers :: IMPORTABLE ;
109
106
self . current_module = parent;
110
107
let vis = self . resolve_visibility ( & item. vis ) ;
111
108
@@ -268,21 +265,21 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
268
265
ItemStatic ( _, m, _) => {
269
266
let mutbl = m == hir:: MutMutable ;
270
267
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) ) ;
272
269
}
273
270
ItemConst ( _, _) => {
274
271
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) ) ;
276
273
}
277
274
ItemFn ( _, _, _, _, _, _) => {
278
275
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) ) ;
280
277
}
281
278
282
279
// These items live in the type namespace.
283
280
ItemTy ( ..) => {
284
281
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) ) ;
286
283
}
287
284
288
285
ItemEnum ( ref enum_definition, _) => {
@@ -301,13 +298,13 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
301
298
ItemStruct ( ref struct_def, _) => {
302
299
// Define a name in the type namespace.
303
300
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) ) ;
305
302
306
303
// If this is a newtype or unit-like struct, define a name
307
304
// in the value namespace as well
308
305
if !struct_def. is_struct ( ) {
309
306
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) ) ;
311
308
}
312
309
313
310
// Record the def ID and fields of this struct.
@@ -339,8 +336,7 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
339
336
hir:: TypeTraitItem ( ..) => ( Def :: AssociatedTy ( def_id, item_def_id) , TypeNS ) ,
340
337
} ;
341
338
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) ) ;
344
340
345
341
self . trait_item_map . insert ( ( item. name , def_id) , item_def_id) ;
346
342
}
@@ -363,19 +359,16 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
363
359
364
360
// Variants are always treated as importable to allow them to be glob used.
365
361
// All variants are defined in both type and value namespaces as future-proofing.
366
- let modifiers = DefModifiers :: IMPORTABLE ;
367
362
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 ) ) ;
371
365
}
372
366
373
367
/// Constructs the reduced graph for one foreign item.
374
368
fn build_reduced_graph_for_foreign_item ( & mut self ,
375
369
foreign_item : & ForeignItem ,
376
370
parent : Module < ' b > ) {
377
371
let name = foreign_item. name ;
378
- let modifiers = DefModifiers :: IMPORTABLE ;
379
372
380
373
let def = match foreign_item. node {
381
374
ForeignItemFn ( ..) => {
@@ -387,7 +380,7 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
387
380
} ;
388
381
self . current_module = parent;
389
382
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) ) ;
391
384
}
392
385
393
386
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> {
422
415
423
416
let name = xcdef. name ;
424
417
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
- } ;
429
418
430
419
match def {
431
420
Def :: Mod ( _) | Def :: ForeignMod ( _) | Def :: Enum ( ..) => {
@@ -439,9 +428,8 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
439
428
debug ! ( "(building reduced graph for external crate) building variant {}" , name) ;
440
429
// Variants are always treated as importable to allow them to be glob used.
441
430
// 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) ) ;
445
433
if self . session . cstore . variant_kind ( variant_id) == Some ( VariantKind :: Struct ) {
446
434
// Not adding fields for variants as they are not accessed with a self receiver
447
435
self . structs . insert ( variant_id, Vec :: new ( ) ) ;
@@ -454,7 +442,7 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
454
442
Def :: Method ( ..) => {
455
443
debug ! ( "(building reduced graph for external crate) building value (fn/static) {}" ,
456
444
name) ;
457
- self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , modifiers , vis) ) ;
445
+ self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , vis) ) ;
458
446
}
459
447
Def :: Trait ( def_id) => {
460
448
debug ! ( "(building reduced graph for external crate) building type {}" , name) ;
@@ -480,16 +468,16 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
480
468
}
481
469
Def :: TyAlias ( ..) | Def :: AssociatedTy ( ..) => {
482
470
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) ) ;
484
472
}
485
473
Def :: Struct ( def_id)
486
474
if self . session . cstore . tuple_struct_definition_if_ctor ( def_id) . is_none ( ) => {
487
475
debug ! ( "(building reduced graph for external crate) building type and value for {}" ,
488
476
name) ;
489
- self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , modifiers , vis) ) ;
477
+ self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , vis) ) ;
490
478
if let Some ( ctor_def_id) = self . session . cstore . struct_ctor_def_id ( def_id) {
491
479
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) ) ;
493
481
}
494
482
495
483
// Record the def ID and fields of this struct.
0 commit comments