@@ -360,21 +360,14 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
360
360
361
361
// These items live in both the type and value namespaces.
362
362
ItemStruct ( ref struct_def, _) => {
363
- // Adding to both Type and Value namespaces or just Type?
364
- let ctor_id = if struct_def. is_struct ( ) {
365
- None
366
- } else {
367
- Some ( struct_def. id ( ) )
368
- } ;
369
-
370
363
// Define a name in the type namespace.
371
364
let def = Def :: Struct ( self . ast_map . local_def_id ( item. id ) ) ;
372
365
self . define ( parent, name, TypeNS , ( def, sp, modifiers) ) ;
373
366
374
367
// If this is a newtype or unit-like struct, define a name
375
368
// in the value namespace as well
376
- if let Some ( cid ) = ctor_id {
377
- let def = Def :: Struct ( self . ast_map . local_def_id ( cid ) ) ;
369
+ if !struct_def . is_struct ( ) {
370
+ let def = Def :: Struct ( self . ast_map . local_def_id ( struct_def . id ( ) ) ) ;
378
371
self . define ( parent, name, ValueNS , ( def, sp, modifiers) ) ;
379
372
}
380
373
@@ -516,31 +509,16 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
516
509
if is_exported {
517
510
self . external_exports . insert ( def. def_id ( ) ) ;
518
511
}
519
- let is_struct_ctor = if let Def :: Struct ( def_id) = def {
520
- self . session . cstore . tuple_struct_definition_if_ctor ( def_id) . is_some ( )
521
- } else {
522
- false
523
- } ;
524
512
525
- // Define a module if necessary.
526
513
match def {
527
- Def :: Mod ( _) |
528
- Def :: ForeignMod ( _) |
529
- Def :: Trait ( ..) |
530
- Def :: Enum ( ..) |
531
- Def :: TyAlias ( ..) if !is_struct_ctor => {
514
+ Def :: Mod ( _) | Def :: ForeignMod ( _) | Def :: Enum ( ..) | Def :: TyAlias ( ..) => {
532
515
debug ! ( "(building reduced graph for external crate) building module {} {}" ,
533
516
final_ident,
534
517
is_public) ;
535
518
let parent_link = ModuleParentLink ( new_parent, name) ;
536
519
let module = self . new_module ( parent_link, Some ( def) , true , is_public) ;
537
520
self . try_define ( new_parent, name, TypeNS , ( module, DUMMY_SP ) ) ;
538
521
}
539
- _ => { }
540
- }
541
-
542
- match def {
543
- Def :: Mod ( _) | Def :: ForeignMod ( _) | Def :: Enum ( ..) | Def :: TyAlias ( ..) => { }
544
522
Def :: Variant ( _, variant_id) => {
545
523
debug ! ( "(building reduced graph for external crate) building variant {}" ,
546
524
final_ident) ;
@@ -585,16 +563,18 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
585
563
self . external_exports . insert ( trait_item_def. def_id ( ) ) ;
586
564
}
587
565
}
566
+
567
+ let parent_link = ModuleParentLink ( new_parent, name) ;
568
+ let module = self . new_module ( parent_link, Some ( def) , true , is_public) ;
569
+ self . try_define ( new_parent, name, TypeNS , ( module, DUMMY_SP ) ) ;
588
570
}
589
571
Def :: AssociatedTy ( ..) => {
590
572
debug ! ( "(building reduced graph for external crate) building type {}" ,
591
573
final_ident) ;
592
574
self . try_define ( new_parent, name, TypeNS , ( def, DUMMY_SP , modifiers) ) ;
593
575
}
594
- Def :: Struct ( ..) if is_struct_ctor => {
595
- // Do nothing
596
- }
597
- Def :: Struct ( def_id) => {
576
+ Def :: Struct ( def_id)
577
+ if self . session . cstore . tuple_struct_definition_if_ctor ( def_id) . is_none ( ) => {
598
578
debug ! ( "(building reduced graph for external crate) building type and value for \
599
579
{}",
600
580
final_ident) ;
@@ -608,6 +588,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
608
588
let fields = self . session . cstore . struct_field_names ( def_id) ;
609
589
self . structs . insert ( def_id, fields) ;
610
590
}
591
+ Def :: Struct ( ..) => { }
611
592
Def :: Local ( ..) |
612
593
Def :: PrimTy ( ..) |
613
594
Def :: TyParam ( ..) |
0 commit comments