@@ -360,21 +360,14 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
360360
361361 // These items live in both the type and value namespaces.
362362 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-
370363 // Define a name in the type namespace.
371364 let def = Def :: Struct ( self . ast_map . local_def_id ( item. id ) ) ;
372365 self . define ( parent, name, TypeNS , ( def, sp, modifiers) ) ;
373366
374367 // If this is a newtype or unit-like struct, define a name
375368 // 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 ( ) ) ) ;
378371 self . define ( parent, name, ValueNS , ( def, sp, modifiers) ) ;
379372 }
380373
@@ -516,31 +509,16 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
516509 if is_exported {
517510 self . external_exports . insert ( def. def_id ( ) ) ;
518511 }
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- } ;
524512
525- // Define a module if necessary.
526513 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 ( ..) => {
532515 debug ! ( "(building reduced graph for external crate) building module {} {}" ,
533516 final_ident,
534517 is_public) ;
535518 let parent_link = ModuleParentLink ( new_parent, name) ;
536519 let module = self . new_module ( parent_link, Some ( def) , true , is_public) ;
537520 self . try_define ( new_parent, name, TypeNS , ( module, DUMMY_SP ) ) ;
538521 }
539- _ => { }
540- }
541-
542- match def {
543- Def :: Mod ( _) | Def :: ForeignMod ( _) | Def :: Enum ( ..) | Def :: TyAlias ( ..) => { }
544522 Def :: Variant ( _, variant_id) => {
545523 debug ! ( "(building reduced graph for external crate) building variant {}" ,
546524 final_ident) ;
@@ -585,16 +563,18 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
585563 self . external_exports . insert ( trait_item_def. def_id ( ) ) ;
586564 }
587565 }
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 ) ) ;
588570 }
589571 Def :: AssociatedTy ( ..) => {
590572 debug ! ( "(building reduced graph for external crate) building type {}" ,
591573 final_ident) ;
592574 self . try_define ( new_parent, name, TypeNS , ( def, DUMMY_SP , modifiers) ) ;
593575 }
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 ( ) => {
598578 debug ! ( "(building reduced graph for external crate) building type and value for \
599579 {}",
600580 final_ident) ;
@@ -608,6 +588,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
608588 let fields = self . session . cstore . struct_field_names ( def_id) ;
609589 self . structs . insert ( def_id, fields) ;
610590 }
591+ Def :: Struct ( ..) => { }
611592 Def :: Local ( ..) |
612593 Def :: PrimTy ( ..) |
613594 Def :: TyParam ( ..) |
0 commit comments