@@ -871,6 +871,41 @@ fn should_encode_variances(def_kind: DefKind) -> bool {
871
871
}
872
872
}
873
873
874
+ fn should_encode_generics ( def_kind : DefKind ) -> bool {
875
+ match def_kind {
876
+ DefKind :: Struct
877
+ | DefKind :: Union
878
+ | DefKind :: Enum
879
+ | DefKind :: Variant
880
+ | DefKind :: Trait
881
+ | DefKind :: TyAlias
882
+ | DefKind :: ForeignTy
883
+ | DefKind :: TraitAlias
884
+ | DefKind :: AssocTy
885
+ | DefKind :: Fn
886
+ | DefKind :: Const
887
+ | DefKind :: Static
888
+ | DefKind :: Ctor ( ..)
889
+ | DefKind :: AssocFn
890
+ | DefKind :: AssocConst
891
+ | DefKind :: AnonConst
892
+ | DefKind :: OpaqueTy
893
+ | DefKind :: Impl
894
+ | DefKind :: Closure
895
+ | DefKind :: Generator => true ,
896
+ DefKind :: Mod
897
+ | DefKind :: Field
898
+ | DefKind :: ForeignMod
899
+ | DefKind :: TyParam
900
+ | DefKind :: ConstParam
901
+ | DefKind :: Macro ( ..)
902
+ | DefKind :: Use
903
+ | DefKind :: LifetimeParam
904
+ | DefKind :: GlobalAsm
905
+ | DefKind :: ExternCrate => false ,
906
+ }
907
+ }
908
+
874
909
impl EncodeContext < ' a , ' tcx > {
875
910
fn encode_def_ids ( & mut self ) {
876
911
if self . is_proc_macro {
@@ -903,12 +938,14 @@ impl EncodeContext<'a, 'tcx> {
903
938
let v = self . tcx . variances_of ( def_id) ;
904
939
record ! ( self . tables. variances[ def_id] <- v) ;
905
940
}
906
- let g = tcx. generics_of ( def_id) ;
907
- record ! ( self . tables. generics[ def_id] <- g) ;
908
- record ! ( self . tables. explicit_predicates[ def_id] <- self . tcx. explicit_predicates_of( def_id) ) ;
909
- let inferred_outlives = self . tcx . inferred_outlives_of ( def_id) ;
910
- if !inferred_outlives. is_empty ( ) {
911
- record ! ( self . tables. inferred_outlives[ def_id] <- inferred_outlives) ;
941
+ if should_encode_generics ( def_kind) {
942
+ let g = tcx. generics_of ( def_id) ;
943
+ record ! ( self . tables. generics[ def_id] <- g) ;
944
+ record ! ( self . tables. explicit_predicates[ def_id] <- self . tcx. explicit_predicates_of( def_id) ) ;
945
+ let inferred_outlives = self . tcx . inferred_outlives_of ( def_id) ;
946
+ if !inferred_outlives. is_empty ( ) {
947
+ record ! ( self . tables. inferred_outlives[ def_id] <- inferred_outlives) ;
948
+ }
912
949
}
913
950
}
914
951
let inherent_impls = tcx. crate_inherent_impls ( LOCAL_CRATE ) ;
0 commit comments