Skip to content

Commit

Permalink
rustc_metadata: remove predicates_of and rely on predicates_defined_o…
Browse files Browse the repository at this point in the history
…n alone.
  • Loading branch information
eddyb committed Nov 3, 2019
1 parent 9e528ff commit 71eacef
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 38 deletions.
1 change: 0 additions & 1 deletion src/librustc_metadata/cstore_impl.rs
Expand Up @@ -95,7 +95,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
generics_of => {
tcx.arena.alloc(cdata.get_generics(def_id.index, tcx.sess))
}
predicates_of => { cdata.get_predicates(def_id.index, tcx) }
predicates_defined_on => { cdata.get_predicates_defined_on(def_id.index, tcx) }
super_predicates_of => { cdata.get_super_predicates(def_id.index, tcx) }
trait_def => {
Expand Down
8 changes: 0 additions & 8 deletions src/librustc_metadata/decoder.rs
Expand Up @@ -658,14 +658,6 @@ impl<'a, 'tcx> CrateMetadata {
tcx.alloc_adt_def(did, adt_kind, variants, repr)
}

crate fn get_predicates(
&self,
item_id: DefIndex,
tcx: TyCtxt<'tcx>,
) -> ty::GenericPredicates<'tcx> {
self.root.per_def.predicates.get(self, item_id).unwrap().decode((self, tcx))
}

crate fn get_predicates_defined_on(
&self,
item_id: DefIndex,
Expand Down
37 changes: 9 additions & 28 deletions src/librustc_metadata/encoder.rs
Expand Up @@ -76,7 +76,6 @@ struct PerDefTables<'tcx> {
inherent_impls: PerDefTable<Lazy<[DefIndex]>>,
variances: PerDefTable<Lazy<[ty::Variance]>>,
generics: PerDefTable<Lazy<ty::Generics>>,
predicates: PerDefTable<Lazy<ty::GenericPredicates<'tcx>>>,
predicates_defined_on: PerDefTable<Lazy<ty::GenericPredicates<'tcx>>>,
super_predicates: PerDefTable<Lazy<ty::GenericPredicates<'tcx>>>,

Expand Down Expand Up @@ -524,7 +523,6 @@ impl<'tcx> EncodeContext<'tcx> {
inherent_impls: self.per_def.inherent_impls.encode(&mut self.opaque),
variances: self.per_def.variances.encode(&mut self.opaque),
generics: self.per_def.generics.encode(&mut self.opaque),
predicates: self.per_def.predicates.encode(&mut self.opaque),
predicates_defined_on: self.per_def.predicates_defined_on.encode(&mut self.opaque),
super_predicates: self.per_def.super_predicates.encode(&mut self.opaque),

Expand Down Expand Up @@ -676,7 +674,7 @@ impl EncodeContext<'tcx> {
self.encode_variances_of(def_id);
}
self.encode_generics(def_id);
self.encode_predicates(def_id);
self.encode_predicates_defined_on(def_id);
self.encode_optimized_mir(def_id);
self.encode_promoted_mir(def_id);
}
Expand Down Expand Up @@ -719,7 +717,7 @@ impl EncodeContext<'tcx> {
self.encode_variances_of(def_id);
}
self.encode_generics(def_id);
self.encode_predicates(def_id);
self.encode_predicates_defined_on(def_id);
self.encode_optimized_mir(def_id);
self.encode_promoted_mir(def_id);
}
Expand Down Expand Up @@ -777,7 +775,7 @@ impl EncodeContext<'tcx> {
self.encode_deprecation(def_id);
self.encode_item_type(def_id);
self.encode_generics(def_id);
self.encode_predicates(def_id);
self.encode_predicates_defined_on(def_id);
}

fn encode_struct_ctor(&mut self, adt_def_id: DefId, def_id: DefId) {
Expand Down Expand Up @@ -820,7 +818,7 @@ impl EncodeContext<'tcx> {
self.encode_variances_of(def_id);
}
self.encode_generics(def_id);
self.encode_predicates(def_id);
self.encode_predicates_defined_on(def_id);
self.encode_optimized_mir(def_id);
self.encode_promoted_mir(def_id);
}
Expand All @@ -830,11 +828,6 @@ impl EncodeContext<'tcx> {
record!(self.per_def.generics[def_id] <- self.tcx.generics_of(def_id));
}

fn encode_predicates(&mut self, def_id: DefId) {
debug!("EncodeContext::encode_predicates({:?})", def_id);
record!(self.per_def.predicates[def_id] <- self.tcx.predicates_of(def_id));
}

fn encode_predicates_defined_on(&mut self, def_id: DefId) {
debug!("EncodeContext::encode_predicates_defined_on({:?})", def_id);
record!(self.per_def.predicates_defined_on[def_id] <-
Expand Down Expand Up @@ -920,7 +913,7 @@ impl EncodeContext<'tcx> {
self.encode_variances_of(def_id);
}
self.encode_generics(def_id);
self.encode_predicates(def_id);
self.encode_predicates_defined_on(def_id);
self.encode_optimized_mir(def_id);
self.encode_promoted_mir(def_id);
}
Expand Down Expand Up @@ -987,7 +980,7 @@ impl EncodeContext<'tcx> {
self.encode_variances_of(def_id);
}
self.encode_generics(def_id);
self.encode_predicates(def_id);
self.encode_predicates_defined_on(def_id);
let mir = match ast_item.kind {
hir::ImplItemKind::Const(..) => true,
hir::ImplItemKind::Method(ref sig, _) => {
Expand Down Expand Up @@ -1261,21 +1254,9 @@ impl EncodeContext<'tcx> {
hir::ItemKind::Trait(..) |
hir::ItemKind::TraitAlias(..) => {
self.encode_generics(def_id);
self.encode_predicates(def_id);
}
_ => {}
}
// The only time that `predicates_defined_on` is used (on
// an external item) is for traits, during chalk lowering,
// so only encode it in that case as an efficiency
// hack. (No reason not to expand it in the future if
// necessary.)
match item.kind {
hir::ItemKind::Trait(..) |
hir::ItemKind::TraitAlias(..) => {
self.encode_predicates_defined_on(def_id);
}
_ => {} // not *wrong* for other kinds of items, but not needed
_ => {}
}
match item.kind {
hir::ItemKind::Trait(..) |
Expand Down Expand Up @@ -1378,7 +1359,7 @@ impl EncodeContext<'tcx> {
record!(self.per_def.span[def_id] <- self.tcx.def_span(def_id));
self.encode_item_type(def_id);
self.encode_generics(def_id);
self.encode_predicates(def_id);
self.encode_predicates_defined_on(def_id);
self.encode_optimized_mir(def_id);
self.encode_promoted_mir(def_id);
}
Expand Down Expand Up @@ -1589,7 +1570,7 @@ impl EncodeContext<'tcx> {
self.encode_variances_of(def_id);
}
self.encode_generics(def_id);
self.encode_predicates(def_id);
self.encode_predicates_defined_on(def_id);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/librustc_metadata/schema.rs
Expand Up @@ -244,7 +244,6 @@ crate struct LazyPerDefTables<'tcx> {
pub inherent_impls: Lazy!(PerDefTable<Lazy<[DefIndex]>>),
pub variances: Lazy!(PerDefTable<Lazy<[ty::Variance]>>),
pub generics: Lazy!(PerDefTable<Lazy<ty::Generics>>),
pub predicates: Lazy!(PerDefTable<Lazy!(ty::GenericPredicates<'tcx>)>),
pub predicates_defined_on: Lazy!(PerDefTable<Lazy!(ty::GenericPredicates<'tcx>)>),
pub super_predicates: Lazy!(PerDefTable<Lazy!(ty::GenericPredicates<'tcx>)>),

Expand Down

0 comments on commit 71eacef

Please sign in to comment.