@@ -359,6 +359,11 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
359359
360360 // These items live in both the type and value namespaces.
361361 ItemStruct ( ref struct_def, _) => {
362+ let modifiers = match !struct_def. is_struct ( ) {
363+ true => modifiers | DefModifiers :: LINKED_NAMESPACES ,
364+ false => modifiers,
365+ } ;
366+
362367 // Define a name in the type namespace.
363368 let def = Def :: Struct ( self . ast_map . local_def_id ( item. id ) ) ;
364369 self . define ( parent, name, TypeNS , ( def, sp, modifiers) ) ;
@@ -434,7 +439,8 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
434439
435440 // Variants are always treated as importable to allow them to be glob used.
436441 // All variants are defined in both type and value namespaces as future-proofing.
437- let modifiers = DefModifiers :: PUBLIC | DefModifiers :: IMPORTABLE | variant_modifiers;
442+ let modifiers = DefModifiers :: PUBLIC | DefModifiers :: IMPORTABLE | variant_modifiers |
443+ DefModifiers :: LINKED_NAMESPACES ;
438444 let def = Def :: Variant ( item_id, self . ast_map . local_def_id ( variant. node . data . id ( ) ) ) ;
439445
440446 self . define ( parent, name, ValueNS , ( def, variant. span , modifiers) ) ;
@@ -523,7 +529,8 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
523529 final_ident) ;
524530 // Variants are always treated as importable to allow them to be glob used.
525531 // All variants are defined in both type and value namespaces as future-proofing.
526- let modifiers = DefModifiers :: PUBLIC | DefModifiers :: IMPORTABLE ;
532+ let modifiers = DefModifiers :: PUBLIC | DefModifiers :: IMPORTABLE |
533+ DefModifiers :: LINKED_NAMESPACES ;
527534 self . try_define ( new_parent, name, TypeNS , ( def, DUMMY_SP , modifiers) ) ;
528535 self . try_define ( new_parent, name, ValueNS , ( def, DUMMY_SP , modifiers) ) ;
529536 if self . session . cstore . variant_kind ( variant_id) == Some ( VariantKind :: Struct ) {
@@ -577,8 +584,14 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
577584 debug ! ( "(building reduced graph for external crate) building type and value for \
578585 {}",
579586 final_ident) ;
587+ let ctor_def_id = self . session . cstore . struct_ctor_def_id ( def_id) ;
588+ let modifiers = match ctor_def_id {
589+ Some ( _) => modifiers | DefModifiers :: LINKED_NAMESPACES ,
590+ None => modifiers,
591+ } ;
592+
580593 self . try_define ( new_parent, name, TypeNS , ( def, DUMMY_SP , modifiers) ) ;
581- if let Some ( ctor_def_id) = self . session . cstore . struct_ctor_def_id ( def_id ) {
594+ if let Some ( ctor_def_id) = ctor_def_id {
582595 let def = Def :: Struct ( ctor_def_id) ;
583596 self . try_define ( new_parent, name, ValueNS , ( def, DUMMY_SP , modifiers) ) ;
584597 }
0 commit comments