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

@ -112,15 +112,15 @@ impl<M: DepTrackingMapConfig> MemoizationMap for RefCell<DepTrackingMap<M>> {
/// switched to `Map(key)`. Therefore, if `op` makes use of any
/// HIR nodes or shared state accessed through its closure
/// environment, it must explicitly register a read of that
/// state. As an example, see `type_scheme_of_item` in `collect`,
/// state. As an example, see `type_of_item` in `collect`,
/// which looks something like this:
///
/// ```
/// fn type_scheme_of_item(..., item: &hir::Item) -> ty::TypeScheme<'tcx> {
/// fn type_of_item(..., item: &hir::Item) -> Ty<'tcx> {
/// let item_def_id = ccx.tcx.map.local_def_id(it.id);
/// ccx.tcx.tcache.memoized(item_def_id, || {
/// ccx.tcx.item_types.memoized(item_def_id, || {
/// ccx.tcx.dep_graph.read(DepNode::Hir(item_def_id)); // (*)
/// compute_type_scheme_of_item(ccx, item)
/// compute_type_of_item(ccx, item)
/// });
/// }
/// ```

View file

@ -1443,7 +1443,7 @@ impl<'a, 'gcx, 'tcx> Rebuilder<'a, 'gcx, 'tcx> {
match self.tcx.expect_def(cur_ty.id) {
Def::Enum(did) | Def::TyAlias(did) |
Def::Struct(did) | Def::Union(did) => {
let generics = self.tcx.lookup_generics(did);
let generics = self.tcx.item_generics(did);
let expected =
generics.regions.len() as u32;

View file

@ -433,7 +433,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
}
fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool {
let field_type = self.tcx.tables().node_id_to_type(field.id);
let field_type = self.tcx.item_type(self.tcx.map.local_def_id(field.id));
let is_marker_field = match field_type.ty_to_def_id() {
Some(def_id) => self.tcx.lang_items.items().iter().any(|item| *item == Some(def_id)),
_ => false

View file

@ -51,7 +51,7 @@ struct ExprVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
impl<'a, 'gcx, 'tcx> ExprVisitor<'a, 'gcx, 'tcx> {
fn def_id_is_transmute(&self, def_id: DefId) -> bool {
let intrinsic = match self.infcx.tcx.lookup_item_type(def_id).ty.sty {
let intrinsic = match self.infcx.tcx.item_type(def_id).sty {
ty::TyFnDef(.., ref bfty) => bfty.abi == RustIntrinsic,
_ => return false
};

View file

@ -112,7 +112,7 @@ use self::VarKind::*;
use dep_graph::DepNode;
use hir::def::*;
use hir::pat_util;
use ty::{self, Ty, TyCtxt, ParameterEnvironment};
use ty::{self, TyCtxt, ParameterEnvironment};
use traits::{self, Reveal};
use ty::subst::Subst;
use lint;
@ -1440,28 +1440,30 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
}
impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn fn_ret(&self, id: NodeId) -> ty::Binder<Ty<'tcx>> {
let fn_ty = self.ir.tcx.tables().node_id_to_type(id);
match fn_ty.sty {
ty::TyClosure(closure_def_id, substs) =>
self.ir.tcx.closure_type(closure_def_id, substs).sig.output(),
_ => fn_ty.fn_ret()
}
}
fn check_ret(&self,
id: NodeId,
sp: Span,
_fk: FnKind,
fk: FnKind,
entry_ln: LiveNode,
body: &hir::Expr)
{
let fn_ty = if let FnKind::Closure(_) = fk {
self.ir.tcx.tables().node_id_to_type(id)
} else {
self.ir.tcx.item_type(self.ir.tcx.map.local_def_id(id))
};
let fn_ret = match fn_ty.sty {
ty::TyClosure(closure_def_id, substs) =>
self.ir.tcx.closure_type(closure_def_id, substs).sig.output(),
_ => fn_ty.fn_ret()
};
// within the fn body, late-bound regions are liberated
// and must outlive the *call-site* of the function.
let fn_ret =
self.ir.tcx.liberate_late_bound_regions(
self.ir.tcx.region_maps.call_site_extent(id, body.id),
&self.fn_ret(id));
&fn_ret);
if !fn_ret.is_never() && self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() {
let param_env = ParameterEnvironment::for_item(self.ir.tcx, id);

View file

@ -125,7 +125,7 @@ impl<'tcx> Lvalue<'tcx> {
Lvalue::Local(index) =>
LvalueTy::Ty { ty: mir.local_decls[index].ty },
Lvalue::Static(def_id) =>
LvalueTy::Ty { ty: tcx.lookup_item_type(def_id).ty },
LvalueTy::Ty { ty: tcx.item_type(def_id) },
Lvalue::Projection(ref proj) =>
proj.base.ty(mir, tcx).projection_ty(tcx, &proj.elem),
}
@ -188,7 +188,7 @@ impl<'tcx> Rvalue<'tcx> {
))
}
AggregateKind::Adt(def, _, substs, _) => {
Some(tcx.lookup_item_type(def.did).ty.subst(tcx, substs))
Some(tcx.item_type(def.did).subst(tcx, substs))
}
AggregateKind::Closure(did, substs) => {
Some(tcx.mk_closure_from_closure_substs(did, substs))

View file

@ -154,9 +154,13 @@ impl<'a, 'gcx, 'tcx> DeferredObligation<'tcx> {
pub fn try_select(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>)
-> Option<Vec<PredicateObligation<'tcx>>> {
if let ty::TyAnon(def_id, substs) = self.predicate.skip_binder().self_ty().sty {
let ty = if def_id.is_local() {
tcx.item_types.borrow().get(&def_id).cloned()
} else {
Some(tcx.item_type(def_id))
};
// We can resolve the `impl Trait` to its concrete type.
if let Some(ty_scheme) = tcx.opt_lookup_item_type(def_id) {
let concrete_ty = ty_scheme.ty.subst(tcx, substs);
if let Some(concrete_ty) = ty.subst(tcx, substs) {
let predicate = ty::TraitRef {
def_id: self.predicate.def_id(),
substs: tcx.mk_substs_trait(concrete_ty, &[])

View file

@ -603,7 +603,7 @@ pub fn get_vtable_methods<'a, 'tcx>(
// do not hold for this particular set of type parameters.
// Note that this method could then never be called, so we
// do not want to try and trans it, in that case (see #23435).
let predicates = tcx.lookup_predicates(def_id).instantiate_own(tcx, substs);
let predicates = tcx.item_predicates(def_id).instantiate_own(tcx, substs);
if !normalize_and_test_predicates(tcx, predicates.predicates) {
debug!("get_vtable_methods: predicates do not hold");
return None;

View file

@ -129,7 +129,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
let trait_def = self.lookup_trait_def(trait_def_id);
let trait_ref = trait_def.trait_ref.clone();
let trait_ref = trait_ref.to_poly_trait_ref();
let predicates = self.lookup_super_predicates(trait_def_id);
let predicates = self.item_super_predicates(trait_def_id);
predicates
.predicates
.into_iter()
@ -166,7 +166,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
// Search for a predicate like `Self : Sized` amongst the trait bounds.
let free_substs = self.construct_free_substs(def_id,
self.region_maps.node_extent(ast::DUMMY_NODE_ID));
let predicates = self.lookup_predicates(def_id);
let predicates = self.item_predicates(def_id);
let predicates = predicates.instantiate(self, free_substs).predicates;
elaborate_predicates(self, predicates)
.any(|predicate| {
@ -238,7 +238,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
// The `Self` type is erased, so it should not appear in list of
// arguments or return type apart from the receiver.
let ref sig = self.lookup_item_type(method.def_id).ty.fn_sig();
let ref sig = self.item_type(method.def_id).fn_sig();
for &input_ty in &sig.0.inputs[1..] {
if self.contains_illegal_self_type_reference(trait_def_id, input_ty) {
return Some(MethodViolationCode::ReferencesSelf);
@ -249,7 +249,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
// We can't monomorphize things like `fn foo<A>(...)`.
if !self.lookup_generics(method.def_id).types.is_empty() {
if !self.item_generics(method.def_id).types.is_empty() {
return Some(MethodViolationCode::Generic);
}

View file

@ -311,7 +311,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a,
ty::TyAnon(def_id, substs) if !substs.has_escaping_regions() => { // (*)
// Only normalize `impl Trait` after type-checking, usually in trans.
if self.selcx.projection_mode() == Reveal::All {
let generic_ty = self.tcx().lookup_item_type(def_id).ty;
let generic_ty = self.tcx().item_type(def_id);
let concrete_ty = generic_ty.subst(self.tcx(), substs);
self.fold_ty(concrete_ty)
} else {
@ -809,7 +809,7 @@ fn assemble_candidates_from_trait_def<'cx, 'gcx, 'tcx>(
};
// If so, extract what we know from the trait and try to come up with a good answer.
let trait_predicates = selcx.tcx().lookup_predicates(def_id);
let trait_predicates = selcx.tcx().item_predicates(def_id);
let bounds = trait_predicates.instantiate(selcx.tcx(), substs);
let bounds = elaborate_predicates(selcx.tcx(), bounds.predicates);
assemble_candidates_from_predicates(selcx,
@ -1313,7 +1313,7 @@ fn confirm_impl_candidate<'cx, 'gcx, 'tcx>(
obligation.predicate.trait_ref);
tcx.types.err
} else {
tcx.lookup_item_type(node_item.item.def_id).ty
tcx.item_type(node_item.item.def_id)
};
let substs = translate_substs(selcx.infcx(), impl_def_id, substs, node_item.node);
Progress {

View file

@ -1200,7 +1200,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
def_id={:?}, substs={:?}",
def_id, substs);
let item_predicates = self.tcx().lookup_predicates(def_id);
let item_predicates = self.tcx().item_predicates(def_id);
let bounds = item_predicates.instantiate(self.tcx(), substs);
debug!("match_projection_obligation_against_definition_bounds: \
bounds={:?}",
@ -2884,7 +2884,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
// obligation will normalize to `<$0 as Iterator>::Item = $1` and
// `$1: Copy`, so we must ensure the obligations are emitted in
// that order.
let predicates = tcx.lookup_predicates(def_id);
let predicates = tcx.item_predicates(def_id);
assert_eq!(predicates.parent, None);
let predicates = predicates.predicates.iter().flat_map(|predicate| {
let predicate = normalize_with_depth(self, cause.clone(), recursion_depth,

View file

@ -128,7 +128,7 @@ impl<'cx, 'gcx, 'tcx> Elaborator<'cx, 'gcx, 'tcx> {
match *predicate {
ty::Predicate::Trait(ref data) => {
// Predicates declared on the trait.
let predicates = tcx.lookup_super_predicates(data.def_id());
let predicates = tcx.item_super_predicates(data.def_id());
let mut predicates: Vec<_> =
predicates.predicates
@ -295,7 +295,7 @@ impl<'cx, 'gcx, 'tcx> Iterator for SupertraitDefIds<'cx, 'gcx, 'tcx> {
None => { return None; }
};
let predicates = self.tcx.lookup_super_predicates(def_id);
let predicates = self.tcx.item_super_predicates(def_id);
let visited = &mut self.visited;
self.stack.extend(
predicates.predicates
@ -362,7 +362,7 @@ pub fn impl_trait_ref_and_oblig<'a, 'gcx, 'tcx>(selcx: &mut SelectionContext<'a,
let Normalized { value: impl_trait_ref, obligations: normalization_obligations1 } =
super::normalize(selcx, ObligationCause::dummy(), &impl_trait_ref);
let predicates = selcx.tcx().lookup_predicates(impl_def_id);
let predicates = selcx.tcx().item_predicates(impl_def_id);
let predicates = predicates.instantiate(selcx.tcx(), impl_substs);
let Normalized { value: predicates, obligations: normalization_obligations2 } =
super::normalize(selcx, ObligationCause::dummy(), &predicates);

View file

@ -444,7 +444,7 @@ pub struct GlobalCtxt<'tcx> {
pub maybe_unused_trait_imports: NodeSet,
// Records the type of every item.
pub tcache: RefCell<DepTrackingMap<maps::Tcache<'tcx>>>,
pub item_types: RefCell<DepTrackingMap<maps::Types<'tcx>>>,
// Internal cache for metadata decoding. No need to track deps on this.
pub rcache: RefCell<FxHashMap<ty::CReaderCacheKey, Ty<'tcx>>>,
@ -665,10 +665,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
self.ty_param_defs.borrow().get(&node_id).unwrap().clone()
}
pub fn node_type_insert(self, id: NodeId, ty: Ty<'gcx>) {
self.tables.borrow_mut().node_types.insert(id, ty);
}
pub fn alloc_generics(self, generics: ty::Generics<'gcx>)
-> &'gcx ty::Generics<'gcx> {
self.global_interners.arenas.generics.alloc(generics)
@ -815,7 +811,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
mir_map: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
freevars: RefCell::new(freevars),
maybe_unused_trait_imports: maybe_unused_trait_imports,
tcache: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
item_types: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
rcache: RefCell::new(FxHashMap()),
tc_cache: RefCell::new(FxHashMap()),
associated_items: RefCell::new(DepTrackingMap::new(dep_graph.clone())),

View file

@ -218,7 +218,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
// users may find it useful. Currently, we omit the parent if
// the impl is either in the same module as the self-type or
// as the trait.
let self_ty = self.lookup_item_type(impl_def_id).ty;
let self_ty = self.item_type(impl_def_id);
let in_self_mod = match characteristic_def_id_of_type(self_ty) {
None => false,
Some(ty_def_id) => self.parent_def_id(ty_def_id) == Some(parent_def_id),

View file

@ -33,7 +33,7 @@ macro_rules! dep_map_ty {
}
dep_map_ty! { AssociatedItems: AssociatedItems(DefId) -> ty::AssociatedItem }
dep_map_ty! { Tcache: ItemSignature(DefId) -> Ty<'tcx> }
dep_map_ty! { Types: ItemSignature(DefId) -> Ty<'tcx> }
dep_map_ty! { Generics: ItemSignature(DefId) -> &'tcx ty::Generics<'tcx> }
dep_map_ty! { Predicates: ItemSignature(DefId) -> ty::GenericPredicates<'tcx> }
dep_map_ty! { SuperPredicates: ItemSignature(DefId) -> ty::GenericPredicates<'tcx> }

View file

@ -169,9 +169,9 @@ impl<'a, 'gcx, 'tcx> ImplHeader<'tcx> {
let header = ImplHeader {
impl_def_id: impl_def_id,
self_ty: tcx.lookup_item_type(impl_def_id).ty,
self_ty: tcx.item_type(impl_def_id),
trait_ref: tcx.impl_trait_ref(impl_def_id),
predicates: tcx.lookup_predicates(impl_def_id).predicates
predicates: tcx.item_predicates(impl_def_id).predicates
}.subst(tcx, impl_substs);
let traits::Normalized { value: mut header, obligations } =
@ -708,7 +708,7 @@ impl<'a, 'gcx, 'tcx> GenericPredicates<'tcx> {
instantiated: &mut InstantiatedPredicates<'tcx>,
substs: &Substs<'tcx>) {
if let Some(def_id) = self.parent {
tcx.lookup_predicates(def_id).instantiate_into(tcx, instantiated, substs);
tcx.item_predicates(def_id).instantiate_into(tcx, instantiated, substs);
}
instantiated.predicates.extend(self.predicates.iter().map(|p| p.subst(tcx, substs)))
}
@ -1301,31 +1301,6 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
}
}
/// A "type scheme", in ML terminology, is a type combined with some
/// set of generic types that the type is, well, generic over. In Rust
/// terms, it is the "type" of a fn item or struct -- this type will
/// include various generic parameters that must be substituted when
/// the item/struct is referenced. That is called converting the type
/// scheme to a monotype.
///
/// - `generics`: the set of type parameters and their bounds
/// - `ty`: the base types, which may reference the parameters defined
/// in `generics`
///
/// Note that TypeSchemes are also sometimes called "polytypes" (and
/// in fact this struct used to carry that name, so you may find some
/// stray references in a comment or something). We try to reserve the
/// "poly" prefix to refer to higher-ranked things, as in
/// `PolyTraitRef`.
///
/// Note that each item also comes with predicates, see
/// `lookup_predicates`.
#[derive(Clone, Debug)]
pub struct TypeScheme<'tcx> {
pub generics: &'tcx Generics<'tcx>,
pub ty: Ty<'tcx>,
}
bitflags! {
flags AdtFlags: u32 {
const NO_ADT_FLAGS = 0,
@ -1359,8 +1334,6 @@ pub struct VariantDefData<'tcx, 'container: 'tcx> {
}
pub struct FieldDefData<'tcx, 'container: 'tcx> {
/// The field's DefId. NOTE: the fields of tuple-like enum variants
/// are not real items, and don't have entries in tcache etc.
pub did: DefId,
pub name: Name,
pub vis: Visibility,
@ -1541,14 +1514,9 @@ impl<'a, 'gcx, 'tcx, 'container> AdtDefData<'gcx, 'container> {
&self.variants[0]
}
#[inline]
pub fn type_scheme(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> TypeScheme<'gcx> {
tcx.lookup_item_type(self.did)
}
#[inline]
pub fn predicates(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> GenericPredicates<'gcx> {
tcx.lookup_predicates(self.did)
tcx.item_predicates(self.did)
}
/// Returns an iterator over all fields contained
@ -1784,7 +1752,7 @@ impl<'a, 'tcx> AdtDefData<'tcx, 'tcx> {
def_id: sized_trait,
substs: tcx.mk_substs_trait(ty, &[])
}).to_predicate();
let predicates = tcx.lookup_predicates(self.did).predicates;
let predicates = tcx.item_predicates(self.did).predicates;
if predicates.into_iter().any(|p| p == sized_predicate) {
vec![]
} else {
@ -1963,7 +1931,7 @@ impl LvaluePreference {
}
/// Helper for looking things up in the various maps that are populated during
/// typeck::collect (e.g., `tcx.associated_items`, `tcx.tcache`, etc). All of
/// typeck::collect (e.g., `tcx.associated_items`, `tcx.types`, etc). All of
/// these share the pattern that if the id is local, it should have been loaded
/// into the map by the `typeck::collect` phase. If the def-id is external,
/// then we have to go consult the crate loading code (and cache the result for
@ -2351,38 +2319,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
}
// Register a given item type
pub fn register_item_type(self, did: DefId, scheme: TypeScheme<'gcx>) {
self.tcache.borrow_mut().insert(did, scheme.ty);
self.generics.borrow_mut().insert(did, scheme.generics);
}
// If the given item is in an external crate, looks up its type and adds it to
// the type cache. Returns the type parameters and type.
pub fn lookup_item_type(self, did: DefId) -> TypeScheme<'gcx> {
let ty = lookup_locally_or_in_crate_store(
"tcache", did, &self.tcache,
|| self.sess.cstore.item_type(self.global_tcx(), did));
TypeScheme {
ty: ty,
generics: self.lookup_generics(did)
}
}
pub fn opt_lookup_item_type(self, did: DefId) -> Option<TypeScheme<'gcx>> {
if did.krate != LOCAL_CRATE {
return Some(self.lookup_item_type(did));
}
if let Some(ty) = self.tcache.borrow().get(&did).cloned() {
Some(TypeScheme {
ty: ty,
generics: self.lookup_generics(did)
})
} else {
None
}
pub fn item_type(self, did: DefId) -> Ty<'gcx> {
lookup_locally_or_in_crate_store(
"item_types", did, &self.item_types,
|| self.sess.cstore.item_type(self.global_tcx(), did))
}
/// Given the did of a trait, returns its canonical trait ref.
@ -2411,21 +2353,21 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
/// Given the did of an item, returns its generics.
pub fn lookup_generics(self, did: DefId) -> &'gcx Generics<'gcx> {
pub fn item_generics(self, did: DefId) -> &'gcx Generics<'gcx> {
lookup_locally_or_in_crate_store(
"generics", did, &self.generics,
|| self.alloc_generics(self.sess.cstore.item_generics(self.global_tcx(), did)))
}
/// Given the did of an item, returns its full set of predicates.
pub fn lookup_predicates(self, did: DefId) -> GenericPredicates<'gcx> {
pub fn item_predicates(self, did: DefId) -> GenericPredicates<'gcx> {
lookup_locally_or_in_crate_store(
"predicates", did, &self.predicates,
|| self.sess.cstore.item_predicates(self.global_tcx(), did))
}
/// Given the did of a trait, returns its superpredicates.
pub fn lookup_super_predicates(self, did: DefId) -> GenericPredicates<'gcx> {
pub fn item_super_predicates(self, did: DefId) -> GenericPredicates<'gcx> {
lookup_locally_or_in_crate_store(
"super_predicates", did, &self.super_predicates,
|| self.sess.cstore.item_super_predicates(self.global_tcx(), did))
@ -2718,7 +2660,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
//
let tcx = self.global_tcx();
let generic_predicates = tcx.lookup_predicates(def_id);
let generic_predicates = tcx.item_predicates(def_id);
let bounds = generic_predicates.instantiate(tcx, free_substs);
let bounds = tcx.liberate_late_bound_regions(free_id_outlive, &ty::Binder(bounds));
let predicates = bounds.predicates;

View file

@ -164,7 +164,7 @@ pub enum TypeVariants<'tcx> {
/// Anonymized (`impl Trait`) type found in a return type.
/// The DefId comes from the `impl Trait` ast::Ty node, and the
/// substitutions are for the generics of the function in question.
/// After typeck, the concrete type can be found in the `tcache` map.
/// After typeck, the concrete type can be found in the `types` map.
TyAnon(DefId, &'tcx Substs<'tcx>),
/// A type parameter; for example, `T` in `fn f<T>(x: T) {}
@ -556,7 +556,7 @@ pub struct DebruijnIndex {
///
/// These are regions that are stored behind a binder and must be substituted
/// with some concrete region before being used. There are 2 kind of
/// bound regions: early-bound, which are bound in a TypeScheme/TraitDef,
/// bound regions: early-bound, which are bound in an item's Generics,
/// and are substituted by a Substs, and late-bound, which are part of
/// higher-ranked types (e.g. `for<'a> fn(&'a ())`) and are substituted by
/// the likes of `liberate_late_bound_regions`. The distinction exists

View file

@ -177,7 +177,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
-> &'tcx Substs<'tcx>
where FR: FnMut(&ty::RegionParameterDef, &[Kind<'tcx>]) -> &'tcx ty::Region,
FT: FnMut(&ty::TypeParameterDef<'tcx>, &[Kind<'tcx>]) -> Ty<'tcx> {
let defs = tcx.lookup_generics(def_id);
let defs = tcx.item_generics(def_id);
let mut substs = Vec::with_capacity(defs.count());
Substs::fill_item(&mut substs, tcx, defs, &mut mk_region, &mut mk_type);
tcx.intern_substs(&substs)
@ -192,7 +192,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
FT: FnMut(&ty::TypeParameterDef<'tcx>, &[Kind<'tcx>]) -> Ty<'tcx> {
if let Some(def_id) = defs.parent {
let parent_defs = tcx.lookup_generics(def_id);
let parent_defs = tcx.item_generics(def_id);
Substs::fill_item(substs, tcx, parent_defs, mk_region, mk_type);
}
@ -271,7 +271,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
source_ancestor: DefId,
target_substs: &Substs<'tcx>)
-> &'tcx Substs<'tcx> {
let defs = tcx.lookup_generics(source_ancestor);
let defs = tcx.item_generics(source_ancestor);
tcx.mk_substs(target_substs.iter().chain(&self[defs.own_count()..]).cloned())
}
}
@ -519,7 +519,7 @@ impl<'a, 'gcx, 'tcx> ty::TraitRef<'tcx> {
trait_id: DefId,
substs: &Substs<'tcx>)
-> ty::TraitRef<'tcx> {
let defs = tcx.lookup_generics(trait_id);
let defs = tcx.item_generics(trait_id);
ty::TraitRef {
def_id: trait_id,

View file

@ -18,7 +18,7 @@ use std::cell::{Cell, RefCell};
use hir;
use util::nodemap::FxHashMap;
/// As `TypeScheme` but for a trait ref.
/// A trait's definition with type information.
pub struct TraitDef<'tcx> {
pub unsafety: hir::Unsafety,

View file

@ -446,7 +446,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
-> Vec<traits::PredicateObligation<'tcx>>
{
let predicates =
self.infcx.tcx.lookup_predicates(def_id)
self.infcx.tcx.item_predicates(def_id)
.instantiate(self.infcx.tcx, substs);
let cause = self.cause(traits::ItemObligation(def_id));
predicates.predicates

View file

@ -105,7 +105,7 @@ pub fn parameterized(f: &mut fmt::Formatter,
}
}
}
let mut generics = tcx.lookup_generics(item_def_id);
let mut generics = tcx.item_generics(item_def_id);
let mut path_def_id = did;
verbose = tcx.sess.verbose();
has_self = generics.has_self;
@ -115,7 +115,7 @@ pub fn parameterized(f: &mut fmt::Formatter,
// Methods.
assert!(is_value_path);
child_types = generics.types.len();
generics = tcx.lookup_generics(def_id);
generics = tcx.item_generics(def_id);
num_regions = generics.regions.len();
num_types = generics.types.len();
@ -865,7 +865,7 @@ impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> {
TyAdt(def, substs) => {
ty::tls::with(|tcx| {
if def.did.is_local() &&
!tcx.tcache.borrow().contains_key(&def.did) {
!tcx.item_types.borrow().contains_key(&def.did) {
write!(f, "{}<..>", tcx.item_path_str(def.did))
} else {
parameterized(f, substs, def.did, &[])
@ -878,7 +878,7 @@ impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> {
ty::tls::with(|tcx| {
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
// by looking up the projections associated with the def_id.
let item_predicates = tcx.lookup_predicates(def_id);
let item_predicates = tcx.item_predicates(def_id);
let substs = tcx.lift(&substs).unwrap_or_else(|| {
tcx.intern_substs(&[])
});