Split bounds from predicates
This commit is contained in:
parent
a7ead3bd53
commit
d297147e62
10 changed files with 153 additions and 231 deletions
|
@ -937,7 +937,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
|||
.tables
|
||||
.inferred_outlives
|
||||
.get(self, item_id)
|
||||
.map(|predicates| predicates.decode((self, tcx)))
|
||||
.map(|predicates| tcx.arena.alloc_from_iter(predicates.decode((self, tcx))))
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
|
@ -949,6 +949,19 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
|||
self.root.tables.super_predicates.get(self, item_id).unwrap().decode((self, tcx))
|
||||
}
|
||||
|
||||
fn get_explicit_item_bounds(
|
||||
&self,
|
||||
item_id: DefIndex,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
|
||||
self.root
|
||||
.tables
|
||||
.explicit_item_bounds
|
||||
.get(self, item_id)
|
||||
.map(|bounds| tcx.arena.alloc_from_iter(bounds.decode((self, tcx))))
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn get_generics(&self, item_id: DefIndex, sess: &Session) -> ty::Generics {
|
||||
self.root.tables.generics.get(self, item_id).unwrap().decode((self, sess))
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
|||
explicit_predicates_of => { cdata.get_explicit_predicates(def_id.index, tcx) }
|
||||
inferred_outlives_of => { cdata.get_inferred_outlives(def_id.index, tcx) }
|
||||
super_predicates_of => { cdata.get_super_predicates(def_id.index, tcx) }
|
||||
explicit_item_bounds => { cdata.get_explicit_item_bounds(def_id.index, tcx) }
|
||||
trait_def => { cdata.get_trait_def(def_id.index, tcx.sess) }
|
||||
adt_def => { cdata.get_adt_def(def_id.index, tcx) }
|
||||
adt_destructor => {
|
||||
|
|
|
@ -965,6 +965,14 @@ impl EncodeContext<'a, 'tcx> {
|
|||
record!(self.tables.super_predicates[def_id] <- self.tcx.super_predicates_of(def_id));
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -1017,7 +1025,10 @@ impl EncodeContext<'a, 'tcx> {
|
|||
has_self: trait_item.fn_has_self_parameter,
|
||||
}))
|
||||
}
|
||||
ty::AssocKind::Type => EntryKind::AssocType(container),
|
||||
ty::AssocKind::Type => {
|
||||
self.encode_explicit_item_bounds(def_id);
|
||||
EntryKind::AssocType(container)
|
||||
}
|
||||
});
|
||||
record!(self.tables.visibility[def_id] <- trait_item.vis);
|
||||
record!(self.tables.span[def_id] <- ast_item.span);
|
||||
|
|
|
@ -295,13 +295,11 @@ define_tables! {
|
|||
generics: Table<DefIndex, Lazy<ty::Generics>>,
|
||||
explicit_predicates: Table<DefIndex, Lazy!(ty::GenericPredicates<'tcx>)>,
|
||||
expn_that_defined: Table<DefIndex, Lazy<ExpnId>>,
|
||||
// FIXME(eddyb) this would ideally be `Lazy<[...]>` but `ty::Predicate`
|
||||
// doesn't handle shorthands in its own (de)serialization impls,
|
||||
// as it's an `enum` for which we want to derive (de)serialization,
|
||||
// so the `ty::codec` APIs handle the whole `&'tcx [...]` at once.
|
||||
// Also, as an optimization, a missing entry indicates an empty `&[]`.
|
||||
inferred_outlives: Table<DefIndex, Lazy!(&'tcx [(ty::Predicate<'tcx>, Span)])>,
|
||||
// As an optimization, a missing entry indicates an empty `&[]`.
|
||||
inferred_outlives: Table<DefIndex, Lazy!([(ty::Predicate<'tcx>, Span)])>,
|
||||
super_predicates: Table<DefIndex, Lazy!(ty::GenericPredicates<'tcx>)>,
|
||||
// As an optimization, a missing entry indicates an empty `&[]`.
|
||||
explicit_item_bounds: Table<DefIndex, Lazy!([(ty::Predicate<'tcx>, Span)])>,
|
||||
mir: Table<DefIndex, Lazy!(mir::Body<'tcx>)>,
|
||||
promoted_mir: Table<DefIndex, Lazy!(IndexVec<mir::Promoted, mir::Body<'tcx>>)>,
|
||||
mir_abstract_consts: Table<DefIndex, Lazy!(&'tcx [mir::abstract_const::Node<'tcx>])>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue