Skip to content

Commit 478da8f

Browse files
committed
Filter type_of.
1 parent faee780 commit 478da8f

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,41 @@ fn should_encode_generics(def_kind: DefKind) -> bool {
906906
}
907907
}
908908

909+
fn should_encode_type(def_kind: DefKind) -> bool {
910+
match def_kind {
911+
DefKind::Struct
912+
| DefKind::Union
913+
| DefKind::Enum
914+
| DefKind::Variant
915+
| DefKind::TyAlias
916+
| DefKind::ForeignTy
917+
| DefKind::AssocTy
918+
| DefKind::TyParam
919+
| DefKind::Fn
920+
| DefKind::Const
921+
| DefKind::ConstParam
922+
| DefKind::Static
923+
| DefKind::Ctor(..)
924+
| DefKind::AssocFn
925+
| DefKind::AssocConst
926+
| DefKind::AnonConst
927+
| DefKind::OpaqueTy
928+
| DefKind::Field
929+
| DefKind::Impl
930+
| DefKind::Closure
931+
| DefKind::Generator => true,
932+
DefKind::Mod
933+
| DefKind::ForeignMod
934+
| DefKind::Trait
935+
| DefKind::TraitAlias
936+
| DefKind::Macro(..)
937+
| DefKind::Use
938+
| DefKind::LifetimeParam
939+
| DefKind::GlobalAsm
940+
| DefKind::ExternCrate => false,
941+
}
942+
}
943+
909944
impl EncodeContext<'a, 'tcx> {
910945
fn encode_def_ids(&mut self) {
911946
if self.is_proc_macro {
@@ -950,8 +985,10 @@ impl EncodeContext<'a, 'tcx> {
950985
if let DefKind::Trait | DefKind::TraitAlias = def_kind {
951986
record!(self.tables.super_predicates[def_id] <- self.tcx.super_predicates_of(def_id));
952987
}
953-
if let Ok(ty) = self.tcx.try_type_of(def_id) {
954-
record!(self.tables.ty[def_id] <- ty);
988+
if should_encode_type(def_kind) {
989+
if let Ok(ty) = self.tcx.try_type_of(def_id) {
990+
record!(self.tables.ty[def_id] <- ty);
991+
}
955992
}
956993
}
957994
let inherent_impls = tcx.crate_inherent_impls(LOCAL_CRATE);

0 commit comments

Comments
 (0)