Skip to content

Commit

Permalink
Filter fn_sig.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Mar 17, 2021
1 parent 7aedff6 commit 45867ec
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,41 @@ fn should_encode_type(def_kind: DefKind) -> bool {
}
}

fn should_encode_fn_sig(def_kind: DefKind) -> bool {
match def_kind {
DefKind::Variant
| DefKind::TraitAlias
| DefKind::Fn
| DefKind::Ctor(..)
| DefKind::AssocFn => true,
DefKind::Struct
| DefKind::Union
| DefKind::Enum
| DefKind::Trait
| DefKind::TyAlias
| DefKind::ForeignTy
| DefKind::AssocTy
| DefKind::Const
| DefKind::Static
| DefKind::AssocConst
| DefKind::AnonConst
| DefKind::OpaqueTy
| DefKind::Impl
| DefKind::Closure
| DefKind::Generator
| DefKind::Mod
| DefKind::Field
| DefKind::ForeignMod
| DefKind::TyParam
| DefKind::ConstParam
| DefKind::Macro(..)
| DefKind::Use
| DefKind::LifetimeParam
| DefKind::GlobalAsm
| DefKind::ExternCrate => false,
}
}

impl EncodeContext<'a, 'tcx> {
fn encode_def_ids(&mut self) {
if self.is_proc_macro {
Expand Down Expand Up @@ -990,8 +1025,10 @@ impl EncodeContext<'a, 'tcx> {
record!(self.tables.ty[def_id] <- ty);
}
}
if let Ok(sig) = tcx.try_fn_sig(def_id) {
record!(self.tables.fn_sig[def_id] <- sig);
if should_encode_fn_sig(def_kind) {
if let Ok(sig) = tcx.try_fn_sig(def_id) {
record!(self.tables.fn_sig[def_id] <- sig);
}
}
self.encode_explicit_item_bounds(def_id);
}
Expand Down

0 comments on commit 45867ec

Please sign in to comment.