@@ -359,6 +359,11 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
359
359
360
360
// These items live in both the type and value namespaces.
361
361
ItemStruct ( ref struct_def, _) => {
362
+ let modifiers = match !struct_def. is_struct ( ) {
363
+ true => modifiers | DefModifiers :: LINKED_NAMESPACES ,
364
+ false => modifiers,
365
+ } ;
366
+
362
367
// Define a name in the type namespace.
363
368
let def = Def :: Struct ( self . ast_map . local_def_id ( item. id ) ) ;
364
369
self . define ( parent, name, TypeNS , ( def, sp, modifiers) ) ;
@@ -434,7 +439,8 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
434
439
435
440
// Variants are always treated as importable to allow them to be glob used.
436
441
// 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 ;
438
444
let def = Def :: Variant ( item_id, self . ast_map . local_def_id ( variant. node . data . id ( ) ) ) ;
439
445
440
446
self . define ( parent, name, ValueNS , ( def, variant. span , modifiers) ) ;
@@ -523,7 +529,8 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
523
529
final_ident) ;
524
530
// Variants are always treated as importable to allow them to be glob used.
525
531
// 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 ;
527
534
self . try_define ( new_parent, name, TypeNS , ( def, DUMMY_SP , modifiers) ) ;
528
535
self . try_define ( new_parent, name, ValueNS , ( def, DUMMY_SP , modifiers) ) ;
529
536
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> {
577
584
debug ! ( "(building reduced graph for external crate) building type and value for \
578
585
{}",
579
586
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
+
580
593
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 {
582
595
let def = Def :: Struct ( ctor_def_id) ;
583
596
self . try_define ( new_parent, name, ValueNS , ( def, DUMMY_SP , modifiers) ) ;
584
597
}
0 commit comments