@@ -716,6 +716,41 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
716
716
}
717
717
}
718
718
719
+ fn should_encode_visibility ( def_kind : DefKind ) -> bool {
720
+ match def_kind {
721
+ DefKind :: Mod
722
+ | DefKind :: Struct
723
+ | DefKind :: Union
724
+ | DefKind :: Enum
725
+ | DefKind :: Variant
726
+ | DefKind :: Trait
727
+ | DefKind :: TyAlias
728
+ | DefKind :: ForeignTy
729
+ | DefKind :: TraitAlias
730
+ | DefKind :: AssocTy
731
+ | DefKind :: Fn
732
+ | DefKind :: Const
733
+ | DefKind :: Static
734
+ | DefKind :: Ctor ( ..)
735
+ | DefKind :: AssocFn
736
+ | DefKind :: AssocConst
737
+ | DefKind :: Macro ( ..)
738
+ | DefKind :: Use
739
+ | DefKind :: ForeignMod
740
+ | DefKind :: OpaqueTy
741
+ | DefKind :: Impl
742
+ | DefKind :: Field => true ,
743
+ DefKind :: TyParam
744
+ | DefKind :: ConstParam
745
+ | DefKind :: LifetimeParam
746
+ | DefKind :: AnonConst
747
+ | DefKind :: GlobalAsm
748
+ | DefKind :: Closure
749
+ | DefKind :: Generator
750
+ | DefKind :: ExternCrate => false ,
751
+ }
752
+ }
753
+
719
754
impl EncodeContext < ' a , ' tcx > {
720
755
fn encode_def_ids ( & mut self ) {
721
756
if self . is_proc_macro {
@@ -734,6 +769,9 @@ impl EncodeContext<'a, 'tcx> {
734
769
def_kind => def_kind,
735
770
} ) ;
736
771
record ! ( self . tables. span[ def_id] <- tcx. def_span( def_id) ) ;
772
+ if should_encode_visibility ( def_kind) {
773
+ record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
774
+ }
737
775
}
738
776
}
739
777
@@ -761,7 +799,6 @@ impl EncodeContext<'a, 'tcx> {
761
799
} ;
762
800
763
801
record ! ( self . tables. kind[ def_id] <- EntryKind :: Variant ( self . lazy( data) ) ) ;
764
- record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
765
802
record ! ( self . tables. attributes[ def_id] <- & self . tcx. get_attrs( def_id) [ ..] ) ;
766
803
record ! ( self . tables. expn_that_defined[ def_id] <- self . tcx. expansion_that_defined( def_id) ) ;
767
804
record ! ( self . tables. children[ def_id] <- variant. fields. iter( ) . map( |f| {
@@ -800,7 +837,6 @@ impl EncodeContext<'a, 'tcx> {
800
837
} ;
801
838
802
839
record ! ( self . tables. kind[ def_id] <- EntryKind :: Variant ( self . lazy( data) ) ) ;
803
- record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
804
840
self . encode_stability ( def_id) ;
805
841
self . encode_deprecation ( def_id) ;
806
842
self . encode_item_type ( def_id) ;
@@ -851,7 +887,6 @@ impl EncodeContext<'a, 'tcx> {
851
887
} ;
852
888
853
889
record ! ( self . tables. kind[ def_id] <- EntryKind :: Mod ( self . lazy( data) ) ) ;
854
- record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
855
890
record ! ( self . tables. attributes[ def_id] <- attrs) ;
856
891
if self . is_proc_macro {
857
892
record ! ( self . tables. children[ def_id] <- & [ ] ) ;
@@ -881,7 +916,6 @@ impl EncodeContext<'a, 'tcx> {
881
916
let variant_data = tcx. hir ( ) . expect_variant_data ( variant_id) ;
882
917
883
918
record ! ( self . tables. kind[ def_id] <- EntryKind :: Field ) ;
884
- record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
885
919
record ! ( self . tables. attributes[ def_id] <- variant_data. fields( ) [ field_index] . attrs) ;
886
920
record ! ( self . tables. expn_that_defined[ def_id] <- self . tcx. expansion_that_defined( def_id) ) ;
887
921
self . encode_ident_span ( def_id, field. ident ) ;
@@ -906,7 +940,6 @@ impl EncodeContext<'a, 'tcx> {
906
940
} ;
907
941
908
942
record ! ( self . tables. kind[ def_id] <- EntryKind :: Struct ( self . lazy( data) , adt_def. repr) ) ;
909
- record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
910
943
record ! ( self . tables. expn_that_defined[ def_id] <- self . tcx. expansion_that_defined( def_id) ) ;
911
944
self . encode_stability ( def_id) ;
912
945
self . encode_deprecation ( def_id) ;
@@ -1010,7 +1043,6 @@ impl EncodeContext<'a, 'tcx> {
1010
1043
record ! ( self . tables. kind[ def_id] <- EntryKind :: AssocType ( container) ) ;
1011
1044
}
1012
1045
}
1013
- record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
1014
1046
record ! ( self . tables. attributes[ def_id] <- ast_item. attrs) ;
1015
1047
self . encode_ident_span ( def_id, ast_item. ident ) ;
1016
1048
self . encode_stability ( def_id) ;
@@ -1113,7 +1145,6 @@ impl EncodeContext<'a, 'tcx> {
1113
1145
record ! ( self . tables. kind[ def_id] <- EntryKind :: AssocType ( container) ) ;
1114
1146
}
1115
1147
}
1116
- record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
1117
1148
record ! ( self . tables. attributes[ def_id] <- ast_item. attrs) ;
1118
1149
self . encode_ident_span ( def_id, impl_item. ident ) ;
1119
1150
self . encode_stability ( def_id) ;
@@ -1358,7 +1389,6 @@ impl EncodeContext<'a, 'tcx> {
1358
1389
}
1359
1390
} ;
1360
1391
record ! ( self . tables. kind[ def_id] <- entry_kind) ;
1361
- record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
1362
1392
record ! ( self . tables. attributes[ def_id] <- item. attrs) ;
1363
1393
record ! ( self . tables. expn_that_defined[ def_id] <- self . tcx. expansion_that_defined( def_id) ) ;
1364
1394
// FIXME(eddyb) there should be a nicer way to do this.
@@ -1477,7 +1507,6 @@ impl EncodeContext<'a, 'tcx> {
1477
1507
fn encode_info_for_macro_def ( & mut self , macro_def : & hir:: MacroDef < ' _ > ) {
1478
1508
let def_id = self . tcx . hir ( ) . local_def_id ( macro_def. hir_id ) . to_def_id ( ) ;
1479
1509
record ! ( self . tables. kind[ def_id] <- EntryKind :: MacroDef ( self . lazy( macro_def. ast. clone( ) ) ) ) ;
1480
- record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
1481
1510
record ! ( self . tables. attributes[ def_id] <- macro_def. attrs) ;
1482
1511
self . encode_ident_span ( def_id, macro_def. ident ) ;
1483
1512
self . encode_stability ( def_id) ;
@@ -1808,7 +1837,6 @@ impl EncodeContext<'a, 'tcx> {
1808
1837
record ! ( self . tables. kind[ def_id] <- EntryKind :: ForeignType ) ;
1809
1838
}
1810
1839
}
1811
- record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
1812
1840
record ! ( self . tables. attributes[ def_id] <- nitem. attrs) ;
1813
1841
self . encode_ident_span ( def_id, nitem. ident ) ;
1814
1842
self . encode_stability ( def_id) ;
0 commit comments