Rollup merge of #37688 - eddyb:lazy-8, r=petrochenkov

[8/n] rustc: clean up lookup_item_type and remove TypeScheme.

_This is part of a series ([prev](https://github.com/rust-lang/rust/pull/37676) | [next]()) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https://github.com/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well.
If any motivation is unclear, please ask for additional PR description clarifications or code comments._

<hr>

* `tcx.tcache` -> `tcx.item_types`
* `TypeScheme` (grouping `Ty` and `ty::Generics`) is removed
* `tcx.item_types` entries no longer duplicated in `tcx.tables.node_types`
* `tcx.lookup_item_type(def_id).ty` -> `tcx.item_type(def_id)`
* `tcx.lookup_item_type(def_id).generics` -> `tcx.item_generics(def_id)`
* `tcx.lookup_generics(def_id)` -> `tcx.item_generics(def_id)`
* `tcx.lookup_{super_,}predicates(def_id)` -> `tcx.item_{super_,}predicates(def_id)`
This commit is contained in:
Eduard-Mihai Burtescu 2016-11-12 10:38:41 +02:00 committed by GitHub
commit 6dd4ee6d08
61 changed files with 399 additions and 491 deletions

View file

@ -133,7 +133,10 @@ pub fn decode_inlined_item<'a, 'tcx>(cdata: &CrateMetadata,
&InlinedItem::ImplItem(_, ref ii) => ii.id,
};
let inlined_did = tcx.map.local_def_id(item_node_id);
tcx.register_item_type(inlined_did, tcx.lookup_item_type(orig_did));
let ty = tcx.item_type(orig_did);
let generics = tcx.item_generics(orig_did);
tcx.item_types.borrow_mut().insert(inlined_did, ty);
tcx.generics.borrow_mut().insert(inlined_did, generics);
for (id, entry) in ast.side_tables.decode((cdata, tcx, id_ranges)) {
match entry {
@ -141,7 +144,7 @@ pub fn decode_inlined_item<'a, 'tcx>(cdata: &CrateMetadata,
tcx.def_map.borrow_mut().insert(id, def::PathResolution::new(def));
}
TableEntry::NodeType(ty) => {
tcx.node_type_insert(id, ty);
tcx.tables.borrow_mut().node_types.insert(id, ty);
}
TableEntry::ItemSubsts(item_substs) => {
tcx.tables.borrow_mut().item_substs.insert(id, item_substs);

View file

@ -527,7 +527,7 @@ impl<'a, 'tcx> CrateMetadata {
ty::TraitDef::new(data.unsafety,
data.paren_sugar,
tcx.lookup_generics(self.local_def_id(item_id)),
tcx.item_generics(self.local_def_id(item_id)),
data.trait_ref.decode((self, tcx)),
self.def_path(item_id).unwrap().deterministic_hash(tcx))
}

View file

@ -246,7 +246,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
fn encode_item_type(&mut self, def_id: DefId) -> Lazy<Ty<'tcx>> {
let tcx = self.tcx;
self.lazy(&tcx.lookup_item_type(def_id).ty)
self.lazy(&tcx.item_type(def_id))
}
/// Encode data for the given variant of the given ADT. The
@ -444,12 +444,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
fn encode_generics(&mut self, def_id: DefId) -> Lazy<ty::Generics<'tcx>> {
let tcx = self.tcx;
self.lazy(tcx.lookup_generics(def_id))
self.lazy(tcx.item_generics(def_id))
}
fn encode_predicates(&mut self, def_id: DefId) -> Lazy<ty::GenericPredicates<'tcx>> {
let tcx = self.tcx;
self.lazy(&tcx.lookup_predicates(def_id))
self.lazy(&tcx.item_predicates(def_id))
}
fn encode_info_for_trait_item(&mut self, def_id: DefId) -> Entry<'tcx> {
@ -556,7 +556,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
let (ast, mir) = if impl_item.kind == ty::AssociatedKind::Const {
(true, true)
} else if let hir::ImplItemKind::Method(ref sig, _) = ast_item.node {
let generics = self.tcx.lookup_generics(def_id);
let generics = self.tcx.item_generics(def_id);
let types = generics.parent_types as usize + generics.types.len();
let needs_inline = types > 0 || attr::requests_inline(&ast_item.attrs);
let is_const_fn = sig.constness == hir::Constness::Const;
@ -717,7 +717,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
paren_sugar: trait_def.paren_sugar,
has_default_impl: tcx.trait_has_default_impl(def_id),
trait_ref: self.lazy(&trait_def.trait_ref),
super_predicates: self.lazy(&tcx.lookup_super_predicates(def_id)),
super_predicates: self.lazy(&tcx.item_super_predicates(def_id)),
};
EntryKind::Trait(self.lazy(&data))