Skip to content

Commit

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

fn should_encode_explicit_item_bounds(def_kind: DefKind) -> bool {
match def_kind {
DefKind::AssocTy | DefKind::OpaqueTy => true,
DefKind::Variant
| DefKind::TraitAlias
| DefKind::Fn
| DefKind::Ctor(..)
| DefKind::AssocFn
| DefKind::Struct
| DefKind::Union
| DefKind::Enum
| DefKind::Trait
| DefKind::TyAlias
| DefKind::ForeignTy
| DefKind::Const
| DefKind::Static
| DefKind::AssocConst
| DefKind::AnonConst
| 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 @@ -1030,7 +1064,12 @@ impl EncodeContext<'a, 'tcx> {
record!(self.tables.fn_sig[def_id] <- sig);
}
}
self.encode_explicit_item_bounds(def_id);
if should_encode_explicit_item_bounds(def_kind) {
let bounds = self.tcx.explicit_item_bounds(def_id);
if !bounds.is_empty() {
record!(self.tables.explicit_item_bounds[def_id] <- bounds);
}
}
}
let inherent_impls = tcx.crate_inherent_impls(LOCAL_CRATE);
for (def_id, implementations) in inherent_impls.inherent_impls.iter() {
Expand Down Expand Up @@ -1152,14 +1191,6 @@ impl EncodeContext<'a, 'tcx> {
record!(self.tables.kind[def_id] <- EntryKind::Struct(self.lazy(data), adt_def.repr));
}

fn encode_explicit_item_bounds(&mut self, def_id: DefId) {
debug!("EncodeContext::encode_explicit_item_bounds({:?})", def_id);
let bounds = self.tcx.explicit_item_bounds(def_id);
if !bounds.is_empty() {
record!(self.tables.explicit_item_bounds[def_id] <- bounds);
}
}

fn encode_info_for_trait_item(&mut self, def_id: DefId) {
debug!("EncodeContext::encode_info_for_trait_item({:?})", def_id);
let tcx = self.tcx;
Expand Down

0 comments on commit 97008d4

Please sign in to comment.