Auto merge of #41504 - eddyb:query-api, r=nikomatsakis
Improve the librustc on-demand/query API ergonomics. Queries are now performed through these two forms: * `tcx.type_of(def_id)` (the most common usage) * `tcx.at(span).type_of(def_id)` (to provide a more specific location in the cycle stack) Several queries were renamed to work better as method names, i.e. by suffixing with `_of`. r? @nikomatsakis
This commit is contained in:
commit
b0a4074c5e
84 changed files with 508 additions and 557 deletions
|
@ -52,7 +52,7 @@ pub fn construct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
// Find the tables for this body.
|
// Find the tables for this body.
|
||||||
let owner_def_id = tcx.hir.local_def_id(tcx.hir.body_owner(body.id()));
|
let owner_def_id = tcx.hir.local_def_id(tcx.hir.body_owner(body.id()));
|
||||||
let tables = tcx.item_tables(owner_def_id);
|
let tables = tcx.typeck_tables_of(owner_def_id);
|
||||||
|
|
||||||
let mut cfg_builder = CFGBuilder {
|
let mut cfg_builder = CFGBuilder {
|
||||||
tcx: tcx,
|
tcx: tcx,
|
||||||
|
|
|
@ -450,7 +450,7 @@ impl<'a, 'tcx> InferEnv<'a, 'tcx> for hir::BodyId {
|
||||||
Option<ty::TypeckTables<'tcx>>,
|
Option<ty::TypeckTables<'tcx>>,
|
||||||
Option<ty::ParameterEnvironment<'tcx>>) {
|
Option<ty::ParameterEnvironment<'tcx>>) {
|
||||||
let item_id = tcx.hir.body_owner(self);
|
let item_id = tcx.hir.body_owner(self);
|
||||||
(Some(tcx.item_tables(tcx.hir.local_def_id(item_id))),
|
(Some(tcx.typeck_tables_of(tcx.hir.local_def_id(item_id))),
|
||||||
None,
|
None,
|
||||||
Some(ty::ParameterEnvironment::for_item(tcx, item_id)))
|
Some(ty::ParameterEnvironment::for_item(tcx, item_id)))
|
||||||
}
|
}
|
||||||
|
@ -1237,7 +1237,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
substs: &[Kind<'tcx>])
|
substs: &[Kind<'tcx>])
|
||||||
-> Ty<'tcx> {
|
-> Ty<'tcx> {
|
||||||
let default = if def.has_default {
|
let default = if def.has_default {
|
||||||
let default = self.tcx.item_type(def.def_id);
|
let default = self.tcx.type_of(def.def_id);
|
||||||
Some(type_variable::Default {
|
Some(type_variable::Default {
|
||||||
ty: default.subst_spanned(self.tcx, substs, Some(span)),
|
ty: default.subst_spanned(self.tcx, substs, Some(span)),
|
||||||
origin_span: span,
|
origin_span: span,
|
||||||
|
|
|
@ -43,7 +43,7 @@ use std::fmt;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::symbol::Symbol;
|
use syntax::symbol::Symbol;
|
||||||
use syntax_pos::{DUMMY_SP, MultiSpan, Span};
|
use syntax_pos::{MultiSpan, Span};
|
||||||
use errors::{self, Diagnostic, DiagnosticBuilder};
|
use errors::{self, Diagnostic, DiagnosticBuilder};
|
||||||
use hir;
|
use hir;
|
||||||
use hir::def_id::LOCAL_CRATE;
|
use hir::def_id::LOCAL_CRATE;
|
||||||
|
@ -1234,7 +1234,7 @@ fn check_lint_name_cmdline(sess: &Session, lint_cx: &LintStore,
|
||||||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||||
let _task = tcx.dep_graph.in_task(DepNode::LateLintCheck);
|
let _task = tcx.dep_graph.in_task(DepNode::LateLintCheck);
|
||||||
|
|
||||||
let access_levels = &ty::queries::privacy_access_levels::get(tcx, DUMMY_SP, LOCAL_CRATE);
|
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
|
||||||
|
|
||||||
let krate = tcx.hir.krate();
|
let krate = tcx.hir.krate();
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ pub use rustc_const_math::ConstInt;
|
||||||
use hir;
|
use hir;
|
||||||
use hir::def::Def;
|
use hir::def::Def;
|
||||||
use hir::def_id::DefId;
|
use hir::def_id::DefId;
|
||||||
use ty::{self, TyCtxt};
|
use ty::TyCtxt;
|
||||||
use ty::subst::Substs;
|
use ty::subst::Substs;
|
||||||
use util::common::ErrorReported;
|
use util::common::ErrorReported;
|
||||||
use rustc_const_math::*;
|
use rustc_const_math::*;
|
||||||
|
@ -228,7 +228,7 @@ pub fn eval_length(tcx: TyCtxt,
|
||||||
let count_expr = &tcx.hir.body(count).value;
|
let count_expr = &tcx.hir.body(count).value;
|
||||||
let count_def_id = tcx.hir.body_owner_def_id(count);
|
let count_def_id = tcx.hir.body_owner_def_id(count);
|
||||||
let substs = Substs::empty();
|
let substs = Substs::empty();
|
||||||
match ty::queries::const_eval::get(tcx, count_expr.span, (count_def_id, substs)) {
|
match tcx.at(count_expr.span).const_eval((count_def_id, substs)) {
|
||||||
Ok(Integral(Usize(count))) => {
|
Ok(Integral(Usize(count))) => {
|
||||||
let val = count.as_u64(tcx.sess.target.uint_type);
|
let val = count.as_u64(tcx.sess.target.uint_type);
|
||||||
assert_eq!(val as usize as u64, val);
|
assert_eq!(val as usize as u64, val);
|
||||||
|
|
|
@ -26,7 +26,6 @@ use util::nodemap::FxHashSet;
|
||||||
|
|
||||||
use syntax::{ast, codemap};
|
use syntax::{ast, codemap};
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::codemap::DUMMY_SP;
|
|
||||||
use syntax_pos;
|
use syntax_pos;
|
||||||
|
|
||||||
// Any local node that may call something in its body block should be
|
// Any local node that may call something in its body block should be
|
||||||
|
@ -160,7 +159,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
||||||
match item.node {
|
match item.node {
|
||||||
hir::ItemStruct(..) | hir::ItemUnion(..) => {
|
hir::ItemStruct(..) | hir::ItemUnion(..) => {
|
||||||
let def_id = self.tcx.hir.local_def_id(item.id);
|
let def_id = self.tcx.hir.local_def_id(item.id);
|
||||||
let def = self.tcx.lookup_adt_def(def_id);
|
let def = self.tcx.adt_def(def_id);
|
||||||
self.struct_has_extern_repr = def.repr.c();
|
self.struct_has_extern_repr = def.repr.c();
|
||||||
|
|
||||||
intravisit::walk_item(self, &item);
|
intravisit::walk_item(self, &item);
|
||||||
|
@ -433,7 +432,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool {
|
fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool {
|
||||||
let field_type = self.tcx.item_type(self.tcx.hir.local_def_id(field.id));
|
let field_type = self.tcx.type_of(self.tcx.hir.local_def_id(field.id));
|
||||||
let is_marker_field = match field_type.ty_to_def_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)),
|
Some(def_id) => self.tcx.lang_items.items().iter().any(|item| *item == Some(def_id)),
|
||||||
_ => false
|
_ => false
|
||||||
|
@ -593,7 +592,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||||
let access_levels = &ty::queries::privacy_access_levels::get(tcx, DUMMY_SP, LOCAL_CRATE);
|
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
|
||||||
let krate = tcx.hir.krate();
|
let krate = tcx.hir.krate();
|
||||||
let live_symbols = find_live(tcx, access_levels, krate);
|
let live_symbols = find_live(tcx, access_levels, krate);
|
||||||
let mut visitor = DeadVisitor { tcx: tcx, live_symbols: live_symbols };
|
let mut visitor = DeadVisitor { tcx: tcx, live_symbols: live_symbols };
|
||||||
|
|
|
@ -998,7 +998,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
Def::Variant(variant_did) |
|
Def::Variant(variant_did) |
|
||||||
Def::VariantCtor(variant_did, ..) => {
|
Def::VariantCtor(variant_did, ..) => {
|
||||||
let enum_did = tcx.parent_def_id(variant_did).unwrap();
|
let enum_did = tcx.parent_def_id(variant_did).unwrap();
|
||||||
let downcast_cmt = if tcx.lookup_adt_def(enum_did).is_univariant() {
|
let downcast_cmt = if tcx.adt_def(enum_did).is_univariant() {
|
||||||
cmt_pat
|
cmt_pat
|
||||||
} else {
|
} else {
|
||||||
let cmt_pat_ty = cmt_pat.ty;
|
let cmt_pat_ty = cmt_pat.ty;
|
||||||
|
|
|
@ -66,7 +66,7 @@ fn unpack_option_like<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> ExprVisitor<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> ExprVisitor<'a, 'gcx, 'tcx> {
|
||||||
fn def_id_is_transmute(&self, def_id: DefId) -> bool {
|
fn def_id_is_transmute(&self, def_id: DefId) -> bool {
|
||||||
let intrinsic = match self.infcx.tcx.item_type(def_id).sty {
|
let intrinsic = match self.infcx.tcx.type_of(def_id).sty {
|
||||||
ty::TyFnDef(.., bfty) => bfty.abi() == RustIntrinsic,
|
ty::TyFnDef(.., bfty) => bfty.abi() == RustIntrinsic,
|
||||||
_ => return false
|
_ => return false
|
||||||
};
|
};
|
||||||
|
|
|
@ -1426,7 +1426,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||||
entry_ln: LiveNode,
|
entry_ln: LiveNode,
|
||||||
body: &hir::Body)
|
body: &hir::Body)
|
||||||
{
|
{
|
||||||
let fn_ty = self.ir.tcx.item_type(self.ir.tcx.hir.local_def_id(id));
|
let fn_ty = self.ir.tcx.type_of(self.ir.tcx.hir.local_def_id(id));
|
||||||
let fn_sig = match fn_ty.sty {
|
let fn_sig = match fn_ty.sty {
|
||||||
ty::TyClosure(closure_def_id, substs) => {
|
ty::TyClosure(closure_def_id, substs) => {
|
||||||
self.ir.tcx.closure_type(closure_def_id)
|
self.ir.tcx.closure_type(closure_def_id)
|
||||||
|
|
|
@ -1159,7 +1159,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
Def::VariantCtor(variant_did, ..) => {
|
Def::VariantCtor(variant_did, ..) => {
|
||||||
// univariant enums do not need downcasts
|
// univariant enums do not need downcasts
|
||||||
let enum_did = self.tcx().parent_def_id(variant_did).unwrap();
|
let enum_did = self.tcx().parent_def_id(variant_did).unwrap();
|
||||||
if !self.tcx().lookup_adt_def(enum_did).is_univariant() {
|
if !self.tcx().adt_def(enum_did).is_univariant() {
|
||||||
self.cat_downcast(pat, cmt.clone(), cmt.ty, variant_did)
|
self.cat_downcast(pat, cmt.clone(), cmt.ty, variant_did)
|
||||||
} else {
|
} else {
|
||||||
cmt
|
cmt
|
||||||
|
@ -1177,7 +1177,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
let expected_len = match def {
|
let expected_len = match def {
|
||||||
Def::VariantCtor(def_id, CtorKind::Fn) => {
|
Def::VariantCtor(def_id, CtorKind::Fn) => {
|
||||||
let enum_def = self.tcx().parent_def_id(def_id).unwrap();
|
let enum_def = self.tcx().parent_def_id(def_id).unwrap();
|
||||||
self.tcx().lookup_adt_def(enum_def).variant_with_id(def_id).fields.len()
|
self.tcx().adt_def(enum_def).variant_with_id(def_id).fields.len()
|
||||||
}
|
}
|
||||||
Def::StructCtor(_, CtorKind::Fn) => {
|
Def::StructCtor(_, CtorKind::Fn) => {
|
||||||
match self.pat_ty(&pat)?.sty {
|
match self.pat_ty(&pat)?.sty {
|
||||||
|
|
|
@ -28,7 +28,6 @@ use util::nodemap::{NodeSet, FxHashSet};
|
||||||
use syntax::abi::Abi;
|
use syntax::abi::Abi;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::codemap::DUMMY_SP;
|
|
||||||
use hir;
|
use hir;
|
||||||
use hir::def_id::LOCAL_CRATE;
|
use hir::def_id::LOCAL_CRATE;
|
||||||
use hir::intravisit::{Visitor, NestedVisitorMap};
|
use hir::intravisit::{Visitor, NestedVisitorMap};
|
||||||
|
@ -364,13 +363,13 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_reachable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Rc<NodeSet> {
|
pub fn find_reachable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Rc<NodeSet> {
|
||||||
ty::queries::reachable_set::get(tcx, DUMMY_SP, LOCAL_CRATE)
|
tcx.reachable_set(LOCAL_CRATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) -> Rc<NodeSet> {
|
fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) -> Rc<NodeSet> {
|
||||||
debug_assert!(crate_num == LOCAL_CRATE);
|
debug_assert!(crate_num == LOCAL_CRATE);
|
||||||
|
|
||||||
let access_levels = &ty::queries::privacy_access_levels::get(tcx, DUMMY_SP, LOCAL_CRATE);
|
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
|
||||||
|
|
||||||
let any_library = tcx.sess.crate_types.borrow().iter().any(|ty| {
|
let any_library = tcx.sess.crate_types.borrow().iter().any(|ty| {
|
||||||
*ty == config::CrateTypeRlib || *ty == config::CrateTypeDylib ||
|
*ty == config::CrateTypeRlib || *ty == config::CrateTypeDylib ||
|
||||||
|
|
|
@ -656,7 +656,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||||
let sess = &tcx.sess;
|
let sess = &tcx.sess;
|
||||||
|
|
||||||
let access_levels = &ty::queries::privacy_access_levels::get(tcx, DUMMY_SP, LOCAL_CRATE);
|
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
|
||||||
|
|
||||||
if tcx.stability.borrow().staged_api[&LOCAL_CRATE] && tcx.sess.features.borrow().staged_api {
|
if tcx.stability.borrow().staged_api[&LOCAL_CRATE] && tcx.sess.features.borrow().staged_api {
|
||||||
let krate = tcx.hir.krate();
|
let krate = tcx.hir.krate();
|
||||||
|
|
|
@ -1015,7 +1015,7 @@ impl<'tcx> Operand<'tcx> {
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Operand::Constant(Constant {
|
Operand::Constant(Constant {
|
||||||
span: span,
|
span: span,
|
||||||
ty: tcx.item_type(def_id).subst(tcx, substs),
|
ty: tcx.type_of(def_id).subst(tcx, substs),
|
||||||
literal: Literal::Value { value: ConstVal::Function(def_id, substs) },
|
literal: Literal::Value { value: ConstVal::Function(def_id, substs) },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ impl<'tcx> Rvalue<'tcx> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
AggregateKind::Adt(def, _, substs, _) => {
|
AggregateKind::Adt(def, _, substs, _) => {
|
||||||
tcx.item_type(def.did).subst(tcx, substs)
|
tcx.type_of(def.did).subst(tcx, substs)
|
||||||
}
|
}
|
||||||
AggregateKind::Closure(did, substs) => {
|
AggregateKind::Closure(did, substs) => {
|
||||||
tcx.mk_closure_from_closure_substs(did, substs)
|
tcx.mk_closure_from_closure_substs(did, substs)
|
||||||
|
|
|
@ -258,7 +258,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
let mut self_match_impls = vec![];
|
let mut self_match_impls = vec![];
|
||||||
let mut fuzzy_match_impls = vec![];
|
let mut fuzzy_match_impls = vec![];
|
||||||
|
|
||||||
self.tcx.lookup_trait_def(trait_ref.def_id)
|
self.tcx.trait_def(trait_ref.def_id)
|
||||||
.for_each_relevant_impl(self.tcx, trait_self_ty, |def_id| {
|
.for_each_relevant_impl(self.tcx, trait_self_ty, |def_id| {
|
||||||
let impl_substs = self.fresh_substs_for_item(obligation.cause.span, def_id);
|
let impl_substs = self.fresh_substs_for_item(obligation.cause.span, def_id);
|
||||||
let impl_trait_ref = tcx
|
let impl_trait_ref = tcx
|
||||||
|
@ -314,7 +314,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
let trait_str = self.tcx.item_path_str(trait_ref.def_id);
|
let trait_str = self.tcx.item_path_str(trait_ref.def_id);
|
||||||
if let Some(istring) = item.value_str() {
|
if let Some(istring) = item.value_str() {
|
||||||
let istring = &*istring.as_str();
|
let istring = &*istring.as_str();
|
||||||
let generics = self.tcx.item_generics(trait_ref.def_id);
|
let generics = self.tcx.generics_of(trait_ref.def_id);
|
||||||
let generic_map = generics.types.iter().map(|param| {
|
let generic_map = generics.types.iter().map(|param| {
|
||||||
(param.name.as_str().to_string(),
|
(param.name.as_str().to_string(),
|
||||||
trait_ref.substs.type_for_def(param).to_string())
|
trait_ref.substs.type_for_def(param).to_string())
|
||||||
|
@ -372,7 +372,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
trait_ref.skip_binder().self_ty(),
|
trait_ref.skip_binder().self_ty(),
|
||||||
true);
|
true);
|
||||||
let mut impl_candidates = Vec::new();
|
let mut impl_candidates = Vec::new();
|
||||||
let trait_def = self.tcx.lookup_trait_def(trait_ref.def_id());
|
let trait_def = self.tcx.trait_def(trait_ref.def_id());
|
||||||
|
|
||||||
match simp {
|
match simp {
|
||||||
Some(simp) => trait_def.for_each_impl(self.tcx, |def_id| {
|
Some(simp) => trait_def.for_each_impl(self.tcx, |def_id| {
|
||||||
|
|
|
@ -641,7 +641,7 @@ pub fn get_vtable_methods<'a, 'tcx>(
|
||||||
// do not hold for this particular set of type parameters.
|
// do not hold for this particular set of type parameters.
|
||||||
// Note that this method could then never be called, so we
|
// Note that this method could then never be called, so we
|
||||||
// do not want to try and trans it, in that case (see #23435).
|
// do not want to try and trans it, in that case (see #23435).
|
||||||
let predicates = tcx.item_predicates(def_id).instantiate_own(tcx, substs);
|
let predicates = tcx.predicates_of(def_id).instantiate_own(tcx, substs);
|
||||||
if !normalize_and_test_predicates(tcx, predicates.predicates) {
|
if !normalize_and_test_predicates(tcx, predicates.predicates) {
|
||||||
debug!("get_vtable_methods: predicates do not hold");
|
debug!("get_vtable_methods: predicates do not hold");
|
||||||
return None;
|
return None;
|
||||||
|
|
|
@ -79,7 +79,7 @@ pub enum MethodViolationCode {
|
||||||
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
pub fn is_object_safe(self, trait_def_id: DefId) -> bool {
|
pub fn is_object_safe(self, trait_def_id: DefId) -> bool {
|
||||||
// Because we query yes/no results frequently, we keep a cache:
|
// Because we query yes/no results frequently, we keep a cache:
|
||||||
let def = self.lookup_trait_def(trait_def_id);
|
let def = self.trait_def(trait_def_id);
|
||||||
|
|
||||||
let result = def.object_safety().unwrap_or_else(|| {
|
let result = def.object_safety().unwrap_or_else(|| {
|
||||||
let result = self.object_safety_violations(trait_def_id).is_empty();
|
let result = self.object_safety_violations(trait_def_id).is_empty();
|
||||||
|
@ -167,9 +167,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
substs: Substs::identity_for_item(self, trait_def_id)
|
substs: Substs::identity_for_item(self, trait_def_id)
|
||||||
});
|
});
|
||||||
let predicates = if supertraits_only {
|
let predicates = if supertraits_only {
|
||||||
self.item_super_predicates(trait_def_id)
|
self.super_predicates_of(trait_def_id)
|
||||||
} else {
|
} else {
|
||||||
self.item_predicates(trait_def_id)
|
self.predicates_of(trait_def_id)
|
||||||
};
|
};
|
||||||
predicates
|
predicates
|
||||||
.predicates
|
.predicates
|
||||||
|
@ -208,7 +208,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
// Search for a predicate like `Self : Sized` amongst the trait bounds.
|
// Search for a predicate like `Self : Sized` amongst the trait bounds.
|
||||||
let free_substs = self.construct_free_substs(def_id,
|
let free_substs = self.construct_free_substs(def_id,
|
||||||
self.region_maps.node_extent(ast::DUMMY_NODE_ID));
|
self.region_maps.node_extent(ast::DUMMY_NODE_ID));
|
||||||
let predicates = self.item_predicates(def_id);
|
let predicates = self.predicates_of(def_id);
|
||||||
let predicates = predicates.instantiate(self, free_substs).predicates;
|
let predicates = predicates.instantiate(self, free_substs).predicates;
|
||||||
elaborate_predicates(self, predicates)
|
elaborate_predicates(self, predicates)
|
||||||
.any(|predicate| {
|
.any(|predicate| {
|
||||||
|
@ -281,7 +281,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
// The `Self` type is erased, so it should not appear in list of
|
// The `Self` type is erased, so it should not appear in list of
|
||||||
// arguments or return type apart from the receiver.
|
// arguments or return type apart from the receiver.
|
||||||
let ref sig = self.item_type(method.def_id).fn_sig();
|
let ref sig = self.type_of(method.def_id).fn_sig();
|
||||||
for input_ty in &sig.skip_binder().inputs()[1..] {
|
for input_ty in &sig.skip_binder().inputs()[1..] {
|
||||||
if self.contains_illegal_self_type_reference(trait_def_id, input_ty) {
|
if self.contains_illegal_self_type_reference(trait_def_id, input_ty) {
|
||||||
return Some(MethodViolationCode::ReferencesSelf);
|
return Some(MethodViolationCode::ReferencesSelf);
|
||||||
|
@ -292,7 +292,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can't monomorphize things like `fn foo<A>(...)`.
|
// We can't monomorphize things like `fn foo<A>(...)`.
|
||||||
if !self.item_generics(method.def_id).types.is_empty() {
|
if !self.generics_of(method.def_id).types.is_empty() {
|
||||||
return Some(MethodViolationCode::Generic);
|
return Some(MethodViolationCode::Generic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -279,7 +279,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a,
|
||||||
ty::TyAnon(def_id, substs) if !substs.has_escaping_regions() => { // (*)
|
ty::TyAnon(def_id, substs) if !substs.has_escaping_regions() => { // (*)
|
||||||
// Only normalize `impl Trait` after type-checking, usually in trans.
|
// Only normalize `impl Trait` after type-checking, usually in trans.
|
||||||
if self.selcx.projection_mode() == Reveal::All {
|
if self.selcx.projection_mode() == Reveal::All {
|
||||||
let generic_ty = self.tcx().item_type(def_id);
|
let generic_ty = self.tcx().type_of(def_id);
|
||||||
let concrete_ty = generic_ty.subst(self.tcx(), substs);
|
let concrete_ty = generic_ty.subst(self.tcx(), substs);
|
||||||
self.fold_ty(concrete_ty)
|
self.fold_ty(concrete_ty)
|
||||||
} else {
|
} else {
|
||||||
|
@ -787,7 +787,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.
|
// If so, extract what we know from the trait and try to come up with a good answer.
|
||||||
let trait_predicates = selcx.tcx().item_predicates(def_id);
|
let trait_predicates = selcx.tcx().predicates_of(def_id);
|
||||||
let bounds = trait_predicates.instantiate(selcx.tcx(), substs);
|
let bounds = trait_predicates.instantiate(selcx.tcx(), substs);
|
||||||
let bounds = elaborate_predicates(selcx.tcx(), bounds.predicates);
|
let bounds = elaborate_predicates(selcx.tcx(), bounds.predicates);
|
||||||
assemble_candidates_from_predicates(selcx,
|
assemble_candidates_from_predicates(selcx,
|
||||||
|
@ -1288,7 +1288,7 @@ fn confirm_impl_candidate<'cx, 'gcx, 'tcx>(
|
||||||
obligation.predicate.trait_ref);
|
obligation.predicate.trait_ref);
|
||||||
tcx.types.err
|
tcx.types.err
|
||||||
} else {
|
} else {
|
||||||
tcx.item_type(node_item.item.def_id)
|
tcx.type_of(node_item.item.def_id)
|
||||||
};
|
};
|
||||||
let substs = translate_substs(selcx.infcx(), impl_def_id, substs, node_item.node);
|
let substs = translate_substs(selcx.infcx(), impl_def_id, substs, node_item.node);
|
||||||
Progress {
|
Progress {
|
||||||
|
@ -1317,7 +1317,7 @@ fn assoc_ty_def<'cx, 'gcx, 'tcx>(
|
||||||
-> Option<specialization_graph::NodeItem<ty::AssociatedItem>>
|
-> Option<specialization_graph::NodeItem<ty::AssociatedItem>>
|
||||||
{
|
{
|
||||||
let trait_def_id = selcx.tcx().impl_trait_ref(impl_def_id).unwrap().def_id;
|
let trait_def_id = selcx.tcx().impl_trait_ref(impl_def_id).unwrap().def_id;
|
||||||
let trait_def = selcx.tcx().lookup_trait_def(trait_def_id);
|
let trait_def = selcx.tcx().trait_def(trait_def_id);
|
||||||
|
|
||||||
if !trait_def.is_complete(selcx.tcx()) {
|
if !trait_def.is_complete(selcx.tcx()) {
|
||||||
let impl_node = specialization_graph::Node::Impl(impl_def_id);
|
let impl_node = specialization_graph::Node::Impl(impl_def_id);
|
||||||
|
|
|
@ -842,7 +842,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||||
fn filter_negative_impls(&self, candidate: SelectionCandidate<'tcx>)
|
fn filter_negative_impls(&self, candidate: SelectionCandidate<'tcx>)
|
||||||
-> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
|
-> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
|
||||||
if let ImplCandidate(def_id) = candidate {
|
if let ImplCandidate(def_id) = candidate {
|
||||||
if self.tcx().trait_impl_polarity(def_id) == hir::ImplPolarity::Negative {
|
if self.tcx().impl_polarity(def_id) == hir::ImplPolarity::Negative {
|
||||||
return Err(Unimplemented)
|
return Err(Unimplemented)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1222,8 +1222,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||||
def_id={:?}, substs={:?}",
|
def_id={:?}, substs={:?}",
|
||||||
def_id, substs);
|
def_id, substs);
|
||||||
|
|
||||||
let item_predicates = self.tcx().item_predicates(def_id);
|
let predicates_of = self.tcx().predicates_of(def_id);
|
||||||
let bounds = item_predicates.instantiate(self.tcx(), substs);
|
let bounds = predicates_of.instantiate(self.tcx(), substs);
|
||||||
debug!("match_projection_obligation_against_definition_bounds: \
|
debug!("match_projection_obligation_against_definition_bounds: \
|
||||||
bounds={:?}",
|
bounds={:?}",
|
||||||
bounds);
|
bounds);
|
||||||
|
@ -1432,7 +1432,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||||
{
|
{
|
||||||
debug!("assemble_candidates_from_impls(obligation={:?})", obligation);
|
debug!("assemble_candidates_from_impls(obligation={:?})", obligation);
|
||||||
|
|
||||||
let def = self.tcx().lookup_trait_def(obligation.predicate.def_id());
|
let def = self.tcx().trait_def(obligation.predicate.def_id());
|
||||||
|
|
||||||
def.for_each_relevant_impl(
|
def.for_each_relevant_impl(
|
||||||
self.tcx(),
|
self.tcx(),
|
||||||
|
@ -1947,7 +1947,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||||
// We can resolve the `impl Trait` to its concrete type,
|
// We can resolve the `impl Trait` to its concrete type,
|
||||||
// which enforces a DAG between the functions requiring
|
// which enforces a DAG between the functions requiring
|
||||||
// the auto trait bounds in question.
|
// the auto trait bounds in question.
|
||||||
vec![self.tcx().item_type(def_id).subst(self.tcx(), substs)]
|
vec![self.tcx().type_of(def_id).subst(self.tcx(), substs)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2526,7 +2526,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||||
(&ty::TyAdt(def, substs_a), &ty::TyAdt(_, substs_b)) => {
|
(&ty::TyAdt(def, substs_a), &ty::TyAdt(_, substs_b)) => {
|
||||||
let fields = def
|
let fields = def
|
||||||
.all_fields()
|
.all_fields()
|
||||||
.map(|f| tcx.item_type(f.did))
|
.map(|f| tcx.type_of(f.did))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
// The last field of the structure has to exist and contain type parameters.
|
// The last field of the structure has to exist and contain type parameters.
|
||||||
|
@ -2844,7 +2844,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||||
// obligation will normalize to `<$0 as Iterator>::Item = $1` and
|
// obligation will normalize to `<$0 as Iterator>::Item = $1` and
|
||||||
// `$1: Copy`, so we must ensure the obligations are emitted in
|
// `$1: Copy`, so we must ensure the obligations are emitted in
|
||||||
// that order.
|
// that order.
|
||||||
let predicates = tcx.item_predicates(def_id);
|
let predicates = tcx.predicates_of(def_id);
|
||||||
assert_eq!(predicates.parent, None);
|
assert_eq!(predicates.parent, None);
|
||||||
let predicates = predicates.predicates.iter().flat_map(|predicate| {
|
let predicates = predicates.predicates.iter().flat_map(|predicate| {
|
||||||
let predicate = normalize_with_depth(self, cause.clone(), recursion_depth,
|
let predicate = normalize_with_depth(self, cause.clone(), recursion_depth,
|
||||||
|
|
|
@ -117,7 +117,7 @@ pub fn find_associated_item<'a, 'tcx>(
|
||||||
assert!(!substs.needs_infer());
|
assert!(!substs.needs_infer());
|
||||||
|
|
||||||
let trait_def_id = tcx.trait_id_of_impl(impl_data.impl_def_id).unwrap();
|
let trait_def_id = tcx.trait_id_of_impl(impl_data.impl_def_id).unwrap();
|
||||||
let trait_def = tcx.lookup_trait_def(trait_def_id);
|
let trait_def = tcx.trait_def(trait_def_id);
|
||||||
|
|
||||||
let ancestors = trait_def.ancestors(impl_data.impl_def_id);
|
let ancestors = trait_def.ancestors(impl_data.impl_def_id);
|
||||||
match ancestors.defs(tcx, item.name, item.kind).next() {
|
match ancestors.defs(tcx, item.name, item.kind).next() {
|
||||||
|
@ -175,7 +175,7 @@ pub fn specializes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
// See RFC 1210 for more details and justification.
|
// See RFC 1210 for more details and justification.
|
||||||
|
|
||||||
// Currently we do not allow e.g. a negative impl to specialize a positive one
|
// Currently we do not allow e.g. a negative impl to specialize a positive one
|
||||||
if tcx.trait_impl_polarity(impl1_def_id) != tcx.trait_impl_polarity(impl2_def_id) {
|
if tcx.impl_polarity(impl1_def_id) != tcx.impl_polarity(impl2_def_id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ impl<'cx, 'gcx, 'tcx> Elaborator<'cx, 'gcx, 'tcx> {
|
||||||
match *predicate {
|
match *predicate {
|
||||||
ty::Predicate::Trait(ref data) => {
|
ty::Predicate::Trait(ref data) => {
|
||||||
// Predicates declared on the trait.
|
// Predicates declared on the trait.
|
||||||
let predicates = tcx.item_super_predicates(data.def_id());
|
let predicates = tcx.super_predicates_of(data.def_id());
|
||||||
|
|
||||||
let mut predicates: Vec<_> =
|
let mut predicates: Vec<_> =
|
||||||
predicates.predicates
|
predicates.predicates
|
||||||
|
@ -301,7 +301,7 @@ impl<'cx, 'gcx, 'tcx> Iterator for SupertraitDefIds<'cx, 'gcx, 'tcx> {
|
||||||
None => { return None; }
|
None => { return None; }
|
||||||
};
|
};
|
||||||
|
|
||||||
let predicates = self.tcx.item_super_predicates(def_id);
|
let predicates = self.tcx.super_predicates_of(def_id);
|
||||||
let visited = &mut self.visited;
|
let visited = &mut self.visited;
|
||||||
self.stack.extend(
|
self.stack.extend(
|
||||||
predicates.predicates
|
predicates.predicates
|
||||||
|
@ -368,7 +368,7 @@ pub fn impl_trait_ref_and_oblig<'a, 'gcx, 'tcx>(selcx: &mut SelectionContext<'a,
|
||||||
let Normalized { value: impl_trait_ref, obligations: normalization_obligations1 } =
|
let Normalized { value: impl_trait_ref, obligations: normalization_obligations1 } =
|
||||||
super::normalize(selcx, ObligationCause::dummy(), &impl_trait_ref);
|
super::normalize(selcx, ObligationCause::dummy(), &impl_trait_ref);
|
||||||
|
|
||||||
let predicates = selcx.tcx().item_predicates(impl_def_id);
|
let predicates = selcx.tcx().predicates_of(impl_def_id);
|
||||||
let predicates = predicates.instantiate(selcx.tcx(), impl_substs);
|
let predicates = predicates.instantiate(selcx.tcx(), impl_substs);
|
||||||
let Normalized { value: predicates, obligations: normalization_obligations2 } =
|
let Normalized { value: predicates, obligations: normalization_obligations2 } =
|
||||||
super::normalize(selcx, ObligationCause::dummy(), &predicates);
|
super::normalize(selcx, ObligationCause::dummy(), &predicates);
|
||||||
|
|
|
@ -1258,7 +1258,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
pub fn mk_box(self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
pub fn mk_box(self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
let def_id = self.require_lang_item(lang_items::OwnedBoxLangItem);
|
let def_id = self.require_lang_item(lang_items::OwnedBoxLangItem);
|
||||||
let adt_def = self.lookup_adt_def(def_id);
|
let adt_def = self.adt_def(def_id);
|
||||||
let substs = self.mk_substs(iter::once(Kind::from(ty)));
|
let substs = self.mk_substs(iter::once(Kind::from(ty)));
|
||||||
self.mk_ty(TyAdt(adt_def, substs))
|
self.mk_ty(TyAdt(adt_def, substs))
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ impl<'tcx> InstanceDef<'tcx> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn def_ty<'a>(&self, tcx: ty::TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
|
pub fn def_ty<'a>(&self, tcx: ty::TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
|
||||||
tcx.item_type(self.def_id())
|
tcx.type_of(self.def_id())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -203,7 +203,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
// for local crates, check whether type info is
|
// for local crates, check whether type info is
|
||||||
// available; typeck might not have completed yet
|
// available; typeck might not have completed yet
|
||||||
self.maps.impl_trait_ref.borrow().contains_key(&impl_def_id) &&
|
self.maps.impl_trait_ref.borrow().contains_key(&impl_def_id) &&
|
||||||
self.maps.ty.borrow().contains_key(&impl_def_id)
|
self.maps.type_of.borrow().contains_key(&impl_def_id)
|
||||||
};
|
};
|
||||||
|
|
||||||
if !use_types {
|
if !use_types {
|
||||||
|
@ -215,7 +215,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
// users may find it useful. Currently, we omit the parent if
|
// users may find it useful. Currently, we omit the parent if
|
||||||
// the impl is either in the same module as the self-type or
|
// the impl is either in the same module as the self-type or
|
||||||
// as the trait.
|
// as the trait.
|
||||||
let self_ty = self.item_type(impl_def_id);
|
let self_ty = self.type_of(impl_def_id);
|
||||||
let in_self_mod = match characteristic_def_id_of_type(self_ty) {
|
let in_self_mod = match characteristic_def_id_of_type(self_ty) {
|
||||||
None => false,
|
None => false,
|
||||||
Some(ty_def_id) => self.parent_def_id(ty_def_id) == Some(parent_def_id),
|
Some(ty_def_id) => self.parent_def_id(ty_def_id) == Some(parent_def_id),
|
||||||
|
|
|
@ -21,6 +21,7 @@ use util::nodemap::NodeSet;
|
||||||
|
|
||||||
use rustc_data_structures::indexed_vec::IndexVec;
|
use rustc_data_structures::indexed_vec::IndexVec;
|
||||||
use std::cell::{RefCell, RefMut};
|
use std::cell::{RefCell, RefMut};
|
||||||
|
use std::ops::Deref;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use syntax_pos::{Span, DUMMY_SP};
|
use syntax_pos::{Span, DUMMY_SP};
|
||||||
|
|
||||||
|
@ -175,7 +176,7 @@ impl<M: DepTrackingMapConfig<Key=DefId>> QueryDescription for M {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> QueryDescription for queries::super_predicates<'tcx> {
|
impl<'tcx> QueryDescription for queries::super_predicates_of<'tcx> {
|
||||||
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
|
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
|
||||||
format!("computing the supertraits of `{}`",
|
format!("computing the supertraits of `{}`",
|
||||||
tcx.item_path_str(def_id))
|
tcx.item_path_str(def_id))
|
||||||
|
@ -329,14 +330,6 @@ macro_rules! define_maps {
|
||||||
Self::try_get_with(tcx, span, key, Clone::clone)
|
Self::try_get_with(tcx, span, key, Clone::clone)
|
||||||
}
|
}
|
||||||
|
|
||||||
$(#[$attr])*
|
|
||||||
pub fn get(tcx: TyCtxt<'a, $tcx, 'lcx>, span: Span, key: $K) -> $V {
|
|
||||||
Self::try_get(tcx, span, key).unwrap_or_else(|e| {
|
|
||||||
tcx.report_cycle(e);
|
|
||||||
Value::from_cycle_error(tcx.global_tcx())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn force(tcx: TyCtxt<'a, $tcx, 'lcx>, span: Span, key: $K) {
|
pub fn force(tcx: TyCtxt<'a, $tcx, 'lcx>, span: Span, key: $K) {
|
||||||
// FIXME(eddyb) Move away from using `DepTrackingMap`
|
// FIXME(eddyb) Move away from using `DepTrackingMap`
|
||||||
// so we don't have to explicitly ignore a false edge:
|
// so we don't have to explicitly ignore a false edge:
|
||||||
|
@ -351,6 +344,45 @@ macro_rules! define_maps {
|
||||||
}
|
}
|
||||||
})*
|
})*
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct TyCtxtAt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||||
|
pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||||
|
pub span: Span,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'gcx, 'tcx> Deref for TyCtxtAt<'a, 'gcx, 'tcx> {
|
||||||
|
type Target = TyCtxt<'a, 'gcx, 'tcx>;
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.tcx
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, $tcx, 'lcx> TyCtxt<'a, $tcx, 'lcx> {
|
||||||
|
/// Return a transparent wrapper for `TyCtxt` which uses
|
||||||
|
/// `span` as the location of queries performed through it.
|
||||||
|
pub fn at(self, span: Span) -> TyCtxtAt<'a, $tcx, 'lcx> {
|
||||||
|
TyCtxtAt {
|
||||||
|
tcx: self,
|
||||||
|
span
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$($(#[$attr])*
|
||||||
|
pub fn $name(self, key: $K) -> $V {
|
||||||
|
self.at(DUMMY_SP).$name(key)
|
||||||
|
})*
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, $tcx, 'lcx> TyCtxtAt<'a, $tcx, 'lcx> {
|
||||||
|
$($(#[$attr])*
|
||||||
|
pub fn $name(self, key: $K) -> $V {
|
||||||
|
queries::$name::try_get(self.tcx, self.span, key).unwrap_or_else(|e| {
|
||||||
|
self.report_cycle(e);
|
||||||
|
Value::from_cycle_error(self.global_tcx())
|
||||||
|
})
|
||||||
|
})*
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Providers<$tcx> {
|
pub struct Providers<$tcx> {
|
||||||
$(pub $name: for<'a> fn(TyCtxt<'a, $tcx, $tcx>, $K) -> $V),*
|
$(pub $name: for<'a> fn(TyCtxt<'a, $tcx, $tcx>, $K) -> $V),*
|
||||||
}
|
}
|
||||||
|
@ -380,12 +412,12 @@ macro_rules! define_maps {
|
||||||
// the driver creates (using several `rustc_*` crates).
|
// the driver creates (using several `rustc_*` crates).
|
||||||
define_maps! { <'tcx>
|
define_maps! { <'tcx>
|
||||||
/// Records the type of every item.
|
/// Records the type of every item.
|
||||||
pub ty: ItemSignature(DefId) -> Ty<'tcx>,
|
pub type_of: ItemSignature(DefId) -> Ty<'tcx>,
|
||||||
|
|
||||||
/// Maps from the def-id of an item (trait/struct/enum/fn) to its
|
/// Maps from the def-id of an item (trait/struct/enum/fn) to its
|
||||||
/// associated generics and predicates.
|
/// associated generics and predicates.
|
||||||
pub generics: ItemSignature(DefId) -> &'tcx ty::Generics,
|
pub generics_of: ItemSignature(DefId) -> &'tcx ty::Generics,
|
||||||
pub predicates: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
|
pub predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
|
||||||
|
|
||||||
/// Maps from the def-id of a trait to the list of
|
/// Maps from the def-id of a trait to the list of
|
||||||
/// super-predicates. This is a subset of the full list of
|
/// super-predicates. This is a subset of the full list of
|
||||||
|
@ -393,7 +425,7 @@ define_maps! { <'tcx>
|
||||||
/// evaluate them even during type conversion, often before the
|
/// evaluate them even during type conversion, often before the
|
||||||
/// full predicates are available (note that supertraits have
|
/// full predicates are available (note that supertraits have
|
||||||
/// additional acyclicity requirements).
|
/// additional acyclicity requirements).
|
||||||
pub super_predicates: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
|
pub super_predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
|
||||||
|
|
||||||
/// To avoid cycles within the predicates of a single item we compute
|
/// To avoid cycles within the predicates of a single item we compute
|
||||||
/// per-type-parameter predicates for resolving `T::AssocTy`.
|
/// per-type-parameter predicates for resolving `T::AssocTy`.
|
||||||
|
@ -411,7 +443,7 @@ define_maps! { <'tcx>
|
||||||
|
|
||||||
/// Maps from def-id of a type or region parameter to its
|
/// Maps from def-id of a type or region parameter to its
|
||||||
/// (inferred) variance.
|
/// (inferred) variance.
|
||||||
pub variances: ItemSignature(DefId) -> Rc<Vec<ty::Variance>>,
|
pub variances_of: ItemSignature(DefId) -> Rc<Vec<ty::Variance>>,
|
||||||
|
|
||||||
/// Maps from an impl/trait def-id to a list of the def-ids of its items
|
/// Maps from an impl/trait def-id to a list of the def-ids of its items
|
||||||
pub associated_item_def_ids: AssociatedItemDefIds(DefId) -> Rc<Vec<DefId>>,
|
pub associated_item_def_ids: AssociatedItemDefIds(DefId) -> Rc<Vec<DefId>>,
|
||||||
|
@ -455,7 +487,7 @@ define_maps! { <'tcx>
|
||||||
|
|
||||||
pub typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
|
pub typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
|
||||||
|
|
||||||
pub typeck_tables: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
|
pub typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
|
||||||
|
|
||||||
pub coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (),
|
pub coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (),
|
||||||
|
|
||||||
|
|
|
@ -165,9 +165,9 @@ impl<'a, 'gcx, 'tcx> ImplHeader<'tcx> {
|
||||||
|
|
||||||
let header = ImplHeader {
|
let header = ImplHeader {
|
||||||
impl_def_id: impl_def_id,
|
impl_def_id: impl_def_id,
|
||||||
self_ty: tcx.item_type(impl_def_id),
|
self_ty: tcx.type_of(impl_def_id),
|
||||||
trait_ref: tcx.impl_trait_ref(impl_def_id),
|
trait_ref: tcx.impl_trait_ref(impl_def_id),
|
||||||
predicates: tcx.item_predicates(impl_def_id).predicates
|
predicates: tcx.predicates_of(impl_def_id).predicates
|
||||||
}.subst(tcx, impl_substs);
|
}.subst(tcx, impl_substs);
|
||||||
|
|
||||||
let traits::Normalized { value: mut header, obligations } =
|
let traits::Normalized { value: mut header, obligations } =
|
||||||
|
@ -727,7 +727,7 @@ impl<'a, 'gcx, 'tcx> GenericPredicates<'tcx> {
|
||||||
instantiated: &mut InstantiatedPredicates<'tcx>,
|
instantiated: &mut InstantiatedPredicates<'tcx>,
|
||||||
substs: &Substs<'tcx>) {
|
substs: &Substs<'tcx>) {
|
||||||
if let Some(def_id) = self.parent {
|
if let Some(def_id) = self.parent {
|
||||||
tcx.item_predicates(def_id).instantiate_into(tcx, instantiated, substs);
|
tcx.predicates_of(def_id).instantiate_into(tcx, instantiated, substs);
|
||||||
}
|
}
|
||||||
instantiated.predicates.extend(self.predicates.iter().map(|p| p.subst(tcx, substs)))
|
instantiated.predicates.extend(self.predicates.iter().map(|p| p.subst(tcx, substs)))
|
||||||
}
|
}
|
||||||
|
@ -1633,7 +1633,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn predicates(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> GenericPredicates<'gcx> {
|
pub fn predicates(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> GenericPredicates<'gcx> {
|
||||||
tcx.item_predicates(self.did)
|
tcx.predicates_of(self.did)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over all fields contained
|
/// Returns an iterator over all fields contained
|
||||||
|
@ -1686,7 +1686,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
|
||||||
let mut discr = prev_discr.map_or(initial, |d| d.wrap_incr());
|
let mut discr = prev_discr.map_or(initial, |d| d.wrap_incr());
|
||||||
if let VariantDiscr::Explicit(expr_did) = v.discr {
|
if let VariantDiscr::Explicit(expr_did) = v.discr {
|
||||||
let substs = Substs::empty();
|
let substs = Substs::empty();
|
||||||
match queries::const_eval::get(tcx, DUMMY_SP, (expr_did, substs)) {
|
match tcx.const_eval((expr_did, substs)) {
|
||||||
Ok(ConstVal::Integral(v)) => {
|
Ok(ConstVal::Integral(v)) => {
|
||||||
discr = v;
|
discr = v;
|
||||||
}
|
}
|
||||||
|
@ -1725,7 +1725,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
|
||||||
}
|
}
|
||||||
ty::VariantDiscr::Explicit(expr_did) => {
|
ty::VariantDiscr::Explicit(expr_did) => {
|
||||||
let substs = Substs::empty();
|
let substs = Substs::empty();
|
||||||
match queries::const_eval::get(tcx, DUMMY_SP, (expr_did, substs)) {
|
match tcx.const_eval((expr_did, substs)) {
|
||||||
Ok(ConstVal::Integral(v)) => {
|
Ok(ConstVal::Integral(v)) => {
|
||||||
explicit_value = v;
|
explicit_value = v;
|
||||||
break;
|
break;
|
||||||
|
@ -1760,7 +1760,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn destructor(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Option<Destructor> {
|
pub fn destructor(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Option<Destructor> {
|
||||||
queries::adt_destructor::get(tcx, DUMMY_SP, self.did)
|
tcx.adt_destructor(self.did)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a list of types such that `Self: Sized` if and only
|
/// Returns a list of types such that `Self: Sized` if and only
|
||||||
|
@ -1840,7 +1840,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
|
||||||
def_id: sized_trait,
|
def_id: sized_trait,
|
||||||
substs: tcx.mk_substs_trait(ty, &[])
|
substs: tcx.mk_substs_trait(ty, &[])
|
||||||
}).to_predicate();
|
}).to_predicate();
|
||||||
let predicates = tcx.item_predicates(self.did).predicates;
|
let predicates = tcx.predicates_of(self.did).predicates;
|
||||||
if predicates.into_iter().any(|p| p == sized_predicate) {
|
if predicates.into_iter().any(|p| p == sized_predicate) {
|
||||||
vec![]
|
vec![]
|
||||||
} else {
|
} else {
|
||||||
|
@ -1881,7 +1881,7 @@ impl<'a, 'gcx, 'tcx> VariantDef {
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> FieldDef {
|
impl<'a, 'gcx, 'tcx> FieldDef {
|
||||||
pub fn ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, subst: &Substs<'tcx>) -> Ty<'tcx> {
|
pub fn ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, subst: &Substs<'tcx>) -> Ty<'tcx> {
|
||||||
tcx.item_type(self.did).subst(tcx, subst)
|
tcx.type_of(self.did).subst(tcx, subst)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2042,11 +2042,7 @@ impl<'gcx> ::std::ops::Deref for Attributes<'gcx> {
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
pub fn body_tables(self, body: hir::BodyId) -> &'gcx TypeckTables<'gcx> {
|
pub fn body_tables(self, body: hir::BodyId) -> &'gcx TypeckTables<'gcx> {
|
||||||
self.item_tables(self.hir.body_owner_def_id(body))
|
self.typeck_tables_of(self.hir.body_owner_def_id(body))
|
||||||
}
|
|
||||||
|
|
||||||
pub fn item_tables(self, def_id: DefId) -> &'gcx TypeckTables<'gcx> {
|
|
||||||
queries::typeck_tables::get(self, DUMMY_SP, def_id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expr_span(self, id: NodeId) -> Span {
|
pub fn expr_span(self, id: NodeId) -> Span {
|
||||||
|
@ -2136,24 +2132,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn trait_impl_polarity(self, id: DefId) -> hir::ImplPolarity {
|
|
||||||
queries::impl_polarity::get(self, DUMMY_SP, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn trait_relevant_for_never(self, did: DefId) -> bool {
|
pub fn trait_relevant_for_never(self, did: DefId) -> bool {
|
||||||
self.associated_items(did).any(|item| {
|
self.associated_items(did).any(|item| {
|
||||||
item.relevant_for_never()
|
item.relevant_for_never()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn coerce_unsized_info(self, did: DefId) -> adjustment::CoerceUnsizedInfo {
|
|
||||||
queries::coerce_unsized_info::get(self, DUMMY_SP, did)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn associated_item(self, def_id: DefId) -> AssociatedItem {
|
|
||||||
queries::associated_item::get(self, DUMMY_SP, def_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn associated_item_from_trait_item_ref(self,
|
fn associated_item_from_trait_item_ref(self,
|
||||||
parent_def_id: DefId,
|
parent_def_id: DefId,
|
||||||
parent_vis: &hir::Visibility,
|
parent_vis: &hir::Visibility,
|
||||||
|
@ -2205,10 +2189,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn associated_item_def_ids(self, def_id: DefId) -> Rc<Vec<DefId>> {
|
|
||||||
queries::associated_item_def_ids::get(self, DUMMY_SP, def_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline] // FIXME(#35870) Avoid closures being unexported due to impl Trait.
|
#[inline] // FIXME(#35870) Avoid closures being unexported due to impl Trait.
|
||||||
pub fn associated_items(self, def_id: DefId)
|
pub fn associated_items(self, def_id: DefId)
|
||||||
-> impl Iterator<Item = ty::AssociatedItem> + 'a {
|
-> impl Iterator<Item = ty::AssociatedItem> + 'a {
|
||||||
|
@ -2216,12 +2196,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
(0..def_ids.len()).map(move |i| self.associated_item(def_ids[i]))
|
(0..def_ids.len()).map(move |i| self.associated_item(def_ids[i]))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the trait-ref corresponding to a given impl, or None if it is
|
|
||||||
/// an inherent impl.
|
|
||||||
pub fn impl_trait_ref(self, id: DefId) -> Option<TraitRef<'gcx>> {
|
|
||||||
queries::impl_trait_ref::get(self, DUMMY_SP, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns true if the impls are the same polarity and are implementing
|
/// Returns true if the impls are the same polarity and are implementing
|
||||||
/// a trait which contains no items
|
/// a trait which contains no items
|
||||||
pub fn impls_are_allowed_to_overlap(self, def_id1: DefId, def_id2: DefId) -> bool {
|
pub fn impls_are_allowed_to_overlap(self, def_id1: DefId, def_id2: DefId) -> bool {
|
||||||
|
@ -2236,7 +2210,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
.map_or(false, |trait_ref| {
|
.map_or(false, |trait_ref| {
|
||||||
self.associated_item_def_ids(trait_ref.def_id).is_empty()
|
self.associated_item_def_ids(trait_ref.def_id).is_empty()
|
||||||
});
|
});
|
||||||
self.trait_impl_polarity(def_id1) == self.trait_impl_polarity(def_id2)
|
self.impl_polarity(def_id1) == self.impl_polarity(def_id2)
|
||||||
&& trait1_is_empty
|
&& trait1_is_empty
|
||||||
&& trait2_is_empty
|
&& trait2_is_empty
|
||||||
}
|
}
|
||||||
|
@ -2247,14 +2221,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
match def {
|
match def {
|
||||||
Def::Variant(did) | Def::VariantCtor(did, ..) => {
|
Def::Variant(did) | Def::VariantCtor(did, ..) => {
|
||||||
let enum_did = self.parent_def_id(did).unwrap();
|
let enum_did = self.parent_def_id(did).unwrap();
|
||||||
self.lookup_adt_def(enum_did).variant_with_id(did)
|
self.adt_def(enum_did).variant_with_id(did)
|
||||||
}
|
}
|
||||||
Def::Struct(did) | Def::Union(did) => {
|
Def::Struct(did) | Def::Union(did) => {
|
||||||
self.lookup_adt_def(did).struct_variant()
|
self.adt_def(did).struct_variant()
|
||||||
}
|
}
|
||||||
Def::StructCtor(ctor_did, ..) => {
|
Def::StructCtor(ctor_did, ..) => {
|
||||||
let did = self.parent_def_id(ctor_did).expect("struct ctor has no parent");
|
let did = self.parent_def_id(ctor_did).expect("struct ctor has no parent");
|
||||||
self.lookup_adt_def(did).struct_variant()
|
self.adt_def(did).struct_variant()
|
||||||
}
|
}
|
||||||
_ => bug!("expect_variant_def used with unexpected def {:?}", def)
|
_ => bug!("expect_variant_def used with unexpected def {:?}", def)
|
||||||
}
|
}
|
||||||
|
@ -2323,40 +2297,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 item_type(self, did: DefId) -> Ty<'gcx> {
|
|
||||||
queries::ty::get(self, DUMMY_SP, did)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Given the did of a trait, returns its canonical trait ref.
|
|
||||||
pub fn lookup_trait_def(self, did: DefId) -> &'gcx TraitDef {
|
|
||||||
queries::trait_def::get(self, DUMMY_SP, did)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Given the did of an ADT, return a reference to its definition.
|
|
||||||
pub fn lookup_adt_def(self, did: DefId) -> &'gcx AdtDef {
|
|
||||||
queries::adt_def::get(self, DUMMY_SP, did)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Given the did of an item, returns its generics.
|
|
||||||
pub fn item_generics(self, did: DefId) -> &'gcx Generics {
|
|
||||||
queries::generics::get(self, DUMMY_SP, did)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Given the did of an item, returns its full set of predicates.
|
|
||||||
pub fn item_predicates(self, did: DefId) -> GenericPredicates<'gcx> {
|
|
||||||
queries::predicates::get(self, DUMMY_SP, did)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Given the did of a trait, returns its superpredicates.
|
|
||||||
pub fn item_super_predicates(self, did: DefId) -> GenericPredicates<'gcx> {
|
|
||||||
queries::super_predicates::get(self, DUMMY_SP, did)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Given the did of an item, returns its MIR, borrowed immutably.
|
/// Given the did of an item, returns its MIR, borrowed immutably.
|
||||||
pub fn item_mir(self, did: DefId) -> Ref<'gcx, Mir<'gcx>> {
|
pub fn item_mir(self, did: DefId) -> Ref<'gcx, Mir<'gcx>> {
|
||||||
queries::mir::get(self, DUMMY_SP, did).borrow()
|
self.mir(did).borrow()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the possibly-auto-generated MIR of a (DefId, Subst) pair.
|
/// Return the possibly-auto-generated MIR of a (DefId, Subst) pair.
|
||||||
|
@ -2365,7 +2308,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
{
|
{
|
||||||
match instance {
|
match instance {
|
||||||
ty::InstanceDef::Item(did) if true => self.item_mir(did),
|
ty::InstanceDef::Item(did) if true => self.item_mir(did),
|
||||||
_ => queries::mir_shims::get(self, DUMMY_SP, instance).borrow(),
|
_ => self.mir_shims(instance).borrow(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2397,12 +2340,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
self.get_attrs(did).iter().any(|item| item.check_name(attr))
|
self.get_attrs(did).iter().any(|item| item.check_name(attr))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn item_variances(self, item_id: DefId) -> Rc<Vec<ty::Variance>> {
|
|
||||||
queries::variances::get(self, DUMMY_SP, item_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn trait_has_default_impl(self, trait_def_id: DefId) -> bool {
|
pub fn trait_has_default_impl(self, trait_def_id: DefId) -> bool {
|
||||||
let def = self.lookup_trait_def(trait_def_id);
|
let def = self.trait_def(trait_def_id);
|
||||||
def.flags.get().intersects(TraitFlags::HAS_DEFAULT_IMPL)
|
def.flags.get().intersects(TraitFlags::HAS_DEFAULT_IMPL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2417,7 +2356,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
// metadata and don't need to track edges.
|
// metadata and don't need to track edges.
|
||||||
let _ignore = self.dep_graph.in_ignore();
|
let _ignore = self.dep_graph.in_ignore();
|
||||||
|
|
||||||
let def = self.lookup_trait_def(trait_id);
|
let def = self.trait_def(trait_id);
|
||||||
if def.flags.get().intersects(TraitFlags::HAS_REMOTE_IMPLS) {
|
if def.flags.get().intersects(TraitFlags::HAS_REMOTE_IMPLS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2435,14 +2374,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
def.flags.set(def.flags.get() | TraitFlags::HAS_REMOTE_IMPLS);
|
def.flags.set(def.flags.get() | TraitFlags::HAS_REMOTE_IMPLS);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn closure_kind(self, def_id: DefId) -> ty::ClosureKind {
|
|
||||||
queries::closure_kind::get(self, DUMMY_SP, def_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn closure_type(self, def_id: DefId) -> ty::PolyFnSig<'tcx> {
|
|
||||||
queries::closure_type::get(self, DUMMY_SP, def_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Given the def_id of an impl, return the def_id of the trait it implements.
|
/// Given the def_id of an impl, return the def_id of the trait it implements.
|
||||||
/// If it implements no trait, return `None`.
|
/// If it implements no trait, return `None`.
|
||||||
pub fn trait_id_of_impl(self, def_id: DefId) -> Option<DefId> {
|
pub fn trait_id_of_impl(self, def_id: DefId) -> Option<DefId> {
|
||||||
|
@ -2551,7 +2482,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
//
|
//
|
||||||
|
|
||||||
let tcx = self.global_tcx();
|
let tcx = self.global_tcx();
|
||||||
let generic_predicates = tcx.item_predicates(def_id);
|
let generic_predicates = tcx.predicates_of(def_id);
|
||||||
let bounds = generic_predicates.instantiate(tcx, free_substs);
|
let bounds = generic_predicates.instantiate(tcx, free_substs);
|
||||||
let bounds = tcx.liberate_late_bound_regions(free_id_outlive, &ty::Binder(bounds));
|
let bounds = tcx.liberate_late_bound_regions(free_id_outlive, &ty::Binder(bounds));
|
||||||
let predicates = bounds.predicates;
|
let predicates = bounds.predicates;
|
||||||
|
@ -2675,12 +2606,12 @@ fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||||
fn adt_sized_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn adt_sized_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
def_id: DefId)
|
def_id: DefId)
|
||||||
-> &'tcx [Ty<'tcx>] {
|
-> &'tcx [Ty<'tcx>] {
|
||||||
let def = tcx.lookup_adt_def(def_id);
|
let def = tcx.adt_def(def_id);
|
||||||
|
|
||||||
let result = tcx.intern_type_list(&def.variants.iter().flat_map(|v| {
|
let result = tcx.intern_type_list(&def.variants.iter().flat_map(|v| {
|
||||||
v.fields.last()
|
v.fields.last()
|
||||||
}).flat_map(|f| {
|
}).flat_map(|f| {
|
||||||
def.sized_constraint_for_ty(tcx, tcx.item_type(f.did))
|
def.sized_constraint_for_ty(tcx, tcx.type_of(f.did))
|
||||||
}).collect::<Vec<_>>());
|
}).collect::<Vec<_>>());
|
||||||
|
|
||||||
debug!("adt_sized_constraint: {:?} => {:?}", def, result);
|
debug!("adt_sized_constraint: {:?} => {:?}", def, result);
|
||||||
|
@ -2692,7 +2623,7 @@ fn adt_sized_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
fn adt_dtorck_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn adt_dtorck_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
def_id: DefId)
|
def_id: DefId)
|
||||||
-> DtorckConstraint<'tcx> {
|
-> DtorckConstraint<'tcx> {
|
||||||
let def = tcx.lookup_adt_def(def_id);
|
let def = tcx.adt_def(def_id);
|
||||||
let span = tcx.def_span(def_id);
|
let span = tcx.def_span(def_id);
|
||||||
debug!("dtorck_constraint: {:?}", def);
|
debug!("dtorck_constraint: {:?}", def);
|
||||||
|
|
||||||
|
@ -2700,7 +2631,7 @@ fn adt_dtorck_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
let result = DtorckConstraint {
|
let result = DtorckConstraint {
|
||||||
outlives: vec![],
|
outlives: vec![],
|
||||||
dtorck_types: vec![
|
dtorck_types: vec![
|
||||||
tcx.mk_param_from_def(&tcx.item_generics(def_id).types[0])
|
tcx.mk_param_from_def(&tcx.generics_of(def_id).types[0])
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
debug!("dtorck_constraint: {:?} => {:?}", def, result);
|
debug!("dtorck_constraint: {:?} => {:?}", def, result);
|
||||||
|
@ -2708,7 +2639,7 @@ fn adt_dtorck_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut result = def.all_fields()
|
let mut result = def.all_fields()
|
||||||
.map(|field| tcx.item_type(field.did))
|
.map(|field| tcx.type_of(field.did))
|
||||||
.map(|fty| tcx.dtorck_constraint_for_ty(span, fty, 0, fty))
|
.map(|fty| tcx.dtorck_constraint_for_ty(span, fty, 0, fty))
|
||||||
.collect::<Result<DtorckConstraint, ErrorReported>>()
|
.collect::<Result<DtorckConstraint, ErrorReported>>()
|
||||||
.unwrap_or(DtorckConstraint::empty());
|
.unwrap_or(DtorckConstraint::empty());
|
||||||
|
@ -2765,9 +2696,8 @@ pub fn provide_extern(providers: &mut ty::maps::Providers) {
|
||||||
/// A map for the local crate mapping each type to a vector of its
|
/// A map for the local crate mapping each type to a vector of its
|
||||||
/// inherent impls. This is not meant to be used outside of coherence;
|
/// inherent impls. This is not meant to be used outside of coherence;
|
||||||
/// rather, you should request the vector for a specific type via
|
/// rather, you should request the vector for a specific type via
|
||||||
/// `ty::queries::inherent_impls::get(def_id)` so as to minimize your
|
/// `tcx.inherent_impls(def_id)` so as to minimize your dependencies
|
||||||
/// dependencies (constructing this map requires touching the entire
|
/// (constructing this map requires touching the entire crate).
|
||||||
/// crate).
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct CrateInherentImpls {
|
pub struct CrateInherentImpls {
|
||||||
pub inherent_impls: DefIdMap<Rc<Vec<DefId>>>,
|
pub inherent_impls: DefIdMap<Rc<Vec<DefId>>>,
|
||||||
|
|
|
@ -126,7 +126,7 @@ fn relate_item_substs<'a, 'gcx, 'tcx, R>(relation: &mut R,
|
||||||
|
|
||||||
let variances;
|
let variances;
|
||||||
let opt_variances = if relation.tcx().variance_computed.get() {
|
let opt_variances = if relation.tcx().variance_computed.get() {
|
||||||
variances = relation.tcx().item_variances(item_def_id);
|
variances = relation.tcx().variances_of(item_def_id);
|
||||||
Some(&*variances)
|
Some(&*variances)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
@ -262,7 +262,7 @@ impl<'a, 'gcx, 'acx, 'tcx> ClosureSubsts<'tcx> {
|
||||||
pub fn upvar_tys(self, def_id: DefId, tcx: TyCtxt<'a, 'gcx, 'acx>) ->
|
pub fn upvar_tys(self, def_id: DefId, tcx: TyCtxt<'a, 'gcx, 'acx>) ->
|
||||||
impl Iterator<Item=Ty<'tcx>> + 'tcx
|
impl Iterator<Item=Ty<'tcx>> + 'tcx
|
||||||
{
|
{
|
||||||
let generics = tcx.item_generics(def_id);
|
let generics = tcx.generics_of(def_id);
|
||||||
self.substs[self.substs.len()-generics.own_count()..].iter().map(
|
self.substs[self.substs.len()-generics.own_count()..].iter().map(
|
||||||
|t| t.as_type().expect("unexpected region in upvars"))
|
|t| t.as_type().expect("unexpected region in upvars"))
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ impl<'a, 'gcx, 'tcx> ExistentialPredicate<'tcx> {
|
||||||
(Trait(_), Trait(_)) => Ordering::Equal,
|
(Trait(_), Trait(_)) => Ordering::Equal,
|
||||||
(Projection(ref a), Projection(ref b)) => a.sort_key(tcx).cmp(&b.sort_key(tcx)),
|
(Projection(ref a), Projection(ref b)) => a.sort_key(tcx).cmp(&b.sort_key(tcx)),
|
||||||
(AutoTrait(ref a), AutoTrait(ref b)) =>
|
(AutoTrait(ref a), AutoTrait(ref b)) =>
|
||||||
tcx.lookup_trait_def(*a).def_path_hash.cmp(&tcx.lookup_trait_def(*b).def_path_hash),
|
tcx.trait_def(*a).def_path_hash.cmp(&tcx.trait_def(*b).def_path_hash),
|
||||||
(Trait(_), _) => Ordering::Less,
|
(Trait(_), _) => Ordering::Less,
|
||||||
(Projection(_), Trait(_)) => Ordering::Greater,
|
(Projection(_), Trait(_)) => Ordering::Greater,
|
||||||
(Projection(_), _) => Ordering::Less,
|
(Projection(_), _) => Ordering::Less,
|
||||||
|
@ -841,7 +841,7 @@ impl<'a, 'tcx, 'gcx> ExistentialProjection<'tcx> {
|
||||||
// We want something here that is stable across crate boundaries.
|
// We want something here that is stable across crate boundaries.
|
||||||
// The DefId isn't but the `deterministic_hash` of the corresponding
|
// The DefId isn't but the `deterministic_hash` of the corresponding
|
||||||
// DefPath is.
|
// DefPath is.
|
||||||
let trait_def = tcx.lookup_trait_def(self.trait_ref.def_id);
|
let trait_def = tcx.trait_def(self.trait_ref.def_id);
|
||||||
let def_path_hash = trait_def.def_path_hash;
|
let def_path_hash = trait_def.def_path_hash;
|
||||||
|
|
||||||
// An `ast::Name` is also not stable (it's just an index into an
|
// An `ast::Name` is also not stable (it's just an index into an
|
||||||
|
|
|
@ -185,7 +185,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
|
||||||
-> &'tcx Substs<'tcx>
|
-> &'tcx Substs<'tcx>
|
||||||
where FR: FnMut(&ty::RegionParameterDef, &[Kind<'tcx>]) -> &'tcx ty::Region,
|
where FR: FnMut(&ty::RegionParameterDef, &[Kind<'tcx>]) -> &'tcx ty::Region,
|
||||||
FT: FnMut(&ty::TypeParameterDef, &[Kind<'tcx>]) -> Ty<'tcx> {
|
FT: FnMut(&ty::TypeParameterDef, &[Kind<'tcx>]) -> Ty<'tcx> {
|
||||||
let defs = tcx.item_generics(def_id);
|
let defs = tcx.generics_of(def_id);
|
||||||
let mut substs = Vec::with_capacity(defs.count());
|
let mut substs = Vec::with_capacity(defs.count());
|
||||||
Substs::fill_item(&mut substs, tcx, defs, &mut mk_region, &mut mk_type);
|
Substs::fill_item(&mut substs, tcx, defs, &mut mk_region, &mut mk_type);
|
||||||
tcx.intern_substs(&substs)
|
tcx.intern_substs(&substs)
|
||||||
|
@ -200,7 +200,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
|
||||||
where FR: FnMut(&ty::RegionParameterDef, &[Kind<'tcx>]) -> &'tcx ty::Region,
|
where FR: FnMut(&ty::RegionParameterDef, &[Kind<'tcx>]) -> &'tcx ty::Region,
|
||||||
FT: FnMut(&ty::TypeParameterDef, &[Kind<'tcx>]) -> Ty<'tcx>
|
FT: FnMut(&ty::TypeParameterDef, &[Kind<'tcx>]) -> Ty<'tcx>
|
||||||
{
|
{
|
||||||
let defs = tcx.item_generics(def_id);
|
let defs = tcx.generics_of(def_id);
|
||||||
let mut result = Vec::with_capacity(defs.count());
|
let mut result = Vec::with_capacity(defs.count());
|
||||||
result.extend(self[..].iter().cloned());
|
result.extend(self[..].iter().cloned());
|
||||||
Substs::fill_single(&mut result, defs, &mut mk_region, &mut mk_type);
|
Substs::fill_single(&mut result, defs, &mut mk_region, &mut mk_type);
|
||||||
|
@ -216,7 +216,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
|
||||||
FT: FnMut(&ty::TypeParameterDef, &[Kind<'tcx>]) -> Ty<'tcx> {
|
FT: FnMut(&ty::TypeParameterDef, &[Kind<'tcx>]) -> Ty<'tcx> {
|
||||||
|
|
||||||
if let Some(def_id) = defs.parent {
|
if let Some(def_id) = defs.parent {
|
||||||
let parent_defs = tcx.item_generics(def_id);
|
let parent_defs = tcx.generics_of(def_id);
|
||||||
Substs::fill_item(substs, tcx, parent_defs, mk_region, mk_type);
|
Substs::fill_item(substs, tcx, parent_defs, mk_region, mk_type);
|
||||||
}
|
}
|
||||||
Substs::fill_single(substs, defs, mk_region, mk_type)
|
Substs::fill_single(substs, defs, mk_region, mk_type)
|
||||||
|
@ -297,7 +297,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
|
||||||
source_ancestor: DefId,
|
source_ancestor: DefId,
|
||||||
target_substs: &Substs<'tcx>)
|
target_substs: &Substs<'tcx>)
|
||||||
-> &'tcx Substs<'tcx> {
|
-> &'tcx Substs<'tcx> {
|
||||||
let defs = tcx.item_generics(source_ancestor);
|
let defs = tcx.generics_of(source_ancestor);
|
||||||
tcx.mk_substs(target_substs.iter().chain(&self[defs.own_count()..]).cloned())
|
tcx.mk_substs(target_substs.iter().chain(&self[defs.own_count()..]).cloned())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,7 +553,7 @@ impl<'a, 'gcx, 'tcx> ty::TraitRef<'tcx> {
|
||||||
trait_id: DefId,
|
trait_id: DefId,
|
||||||
substs: &Substs<'tcx>)
|
substs: &Substs<'tcx>)
|
||||||
-> ty::TraitRef<'tcx> {
|
-> ty::TraitRef<'tcx> {
|
||||||
let defs = tcx.item_generics(trait_id);
|
let defs = tcx.generics_of(trait_id);
|
||||||
|
|
||||||
ty::TraitRef {
|
ty::TraitRef {
|
||||||
def_id: trait_id,
|
def_id: trait_id,
|
||||||
|
|
|
@ -369,11 +369,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
||||||
ty::queries::coherent_trait::get(self, DUMMY_SP, (LOCAL_CRATE, drop_trait));
|
self.coherent_trait((LOCAL_CRATE, drop_trait));
|
||||||
|
|
||||||
let mut dtor_did = None;
|
let mut dtor_did = None;
|
||||||
let ty = self.item_type(adt_did);
|
let ty = self.type_of(adt_did);
|
||||||
self.lookup_trait_def(drop_trait).for_each_relevant_impl(self, ty, |impl_did| {
|
self.trait_def(drop_trait).for_each_relevant_impl(self, ty, |impl_did| {
|
||||||
if let Some(item) = self.associated_items(impl_did).next() {
|
if let Some(item) = self.associated_items(impl_did).next() {
|
||||||
if let Ok(()) = validate(self, impl_did) {
|
if let Ok(()) = validate(self, impl_did) {
|
||||||
dtor_did = Some(item.def_id);
|
dtor_did = Some(item.def_id);
|
||||||
|
@ -422,7 +422,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let impl_def_id = self.associated_item(dtor).container.id();
|
let impl_def_id = self.associated_item(dtor).container.id();
|
||||||
let impl_generics = self.item_generics(impl_def_id);
|
let impl_generics = self.generics_of(impl_def_id);
|
||||||
|
|
||||||
// We have a destructor - all the parameters that are not
|
// We have a destructor - all the parameters that are not
|
||||||
// pure_wrt_drop (i.e, don't have a #[may_dangle] attribute)
|
// pure_wrt_drop (i.e, don't have a #[may_dangle] attribute)
|
||||||
|
@ -445,12 +445,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
// <P1, P2, P0>, and then look up which of the impl substs refer to
|
// <P1, P2, P0>, and then look up which of the impl substs refer to
|
||||||
// parameters marked as pure.
|
// parameters marked as pure.
|
||||||
|
|
||||||
let impl_substs = match self.item_type(impl_def_id).sty {
|
let impl_substs = match self.type_of(impl_def_id).sty {
|
||||||
ty::TyAdt(def_, substs) if def_ == def => substs,
|
ty::TyAdt(def_, substs) if def_ == def => substs,
|
||||||
_ => bug!()
|
_ => bug!()
|
||||||
};
|
};
|
||||||
|
|
||||||
let item_substs = match self.item_type(def.did).sty {
|
let item_substs = match self.type_of(def.did).sty {
|
||||||
ty::TyAdt(def_, substs) if def_ == def => substs,
|
ty::TyAdt(def_, substs) if def_ == def => substs,
|
||||||
_ => bug!()
|
_ => bug!()
|
||||||
};
|
};
|
||||||
|
@ -522,7 +522,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
ty::TyAdt(def, substs) => {
|
ty::TyAdt(def, substs) => {
|
||||||
let ty::DtorckConstraint {
|
let ty::DtorckConstraint {
|
||||||
dtorck_types, outlives
|
dtorck_types, outlives
|
||||||
} = ty::queries::adt_dtorck_constraint::get(self, span, def.did);
|
} = self.at(span).adt_dtorck_constraint(def.did);
|
||||||
Ok(ty::DtorckConstraint {
|
Ok(ty::DtorckConstraint {
|
||||||
// FIXME: we can try to recursively `dtorck_constraint_on_ty`
|
// FIXME: we can try to recursively `dtorck_constraint_on_ty`
|
||||||
// there, but that needs some way to handle cycles.
|
// there, but that needs some way to handle cycles.
|
||||||
|
|
|
@ -443,7 +443,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
|
||||||
-> Vec<traits::PredicateObligation<'tcx>>
|
-> Vec<traits::PredicateObligation<'tcx>>
|
||||||
{
|
{
|
||||||
let predicates =
|
let predicates =
|
||||||
self.infcx.tcx.item_predicates(def_id)
|
self.infcx.tcx.predicates_of(def_id)
|
||||||
.instantiate(self.infcx.tcx, substs);
|
.instantiate(self.infcx.tcx, substs);
|
||||||
let cause = self.cause(traits::ItemObligation(def_id));
|
let cause = self.cause(traits::ItemObligation(def_id));
|
||||||
predicates.predicates
|
predicates.predicates
|
||||||
|
|
|
@ -104,7 +104,7 @@ pub fn parameterized(f: &mut fmt::Formatter,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut generics = tcx.item_generics(item_def_id);
|
let mut generics = tcx.generics_of(item_def_id);
|
||||||
let mut path_def_id = did;
|
let mut path_def_id = did;
|
||||||
verbose = tcx.sess.verbose();
|
verbose = tcx.sess.verbose();
|
||||||
has_self = generics.has_self;
|
has_self = generics.has_self;
|
||||||
|
@ -114,7 +114,7 @@ pub fn parameterized(f: &mut fmt::Formatter,
|
||||||
// Methods.
|
// Methods.
|
||||||
assert!(is_value_path);
|
assert!(is_value_path);
|
||||||
child_types = generics.types.len();
|
child_types = generics.types.len();
|
||||||
generics = tcx.item_generics(def_id);
|
generics = tcx.generics_of(def_id);
|
||||||
num_regions = generics.regions.len();
|
num_regions = generics.regions.len();
|
||||||
num_types = generics.types.len();
|
num_types = generics.types.len();
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ pub fn parameterized(f: &mut fmt::Formatter,
|
||||||
if !def.has_default {
|
if !def.has_default {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if tcx.item_type(def.def_id).subst(tcx, substs) != actual {
|
if tcx.type_of(def.def_id).subst(tcx, substs) != actual {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
num_supplied_defaults += 1;
|
num_supplied_defaults += 1;
|
||||||
|
@ -772,11 +772,11 @@ impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> {
|
||||||
ty::tls::with(|tcx| {
|
ty::tls::with(|tcx| {
|
||||||
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
|
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
|
||||||
// by looking up the projections associated with the def_id.
|
// by looking up the projections associated with the def_id.
|
||||||
let item_predicates = tcx.item_predicates(def_id);
|
let predicates_of = tcx.predicates_of(def_id);
|
||||||
let substs = tcx.lift(&substs).unwrap_or_else(|| {
|
let substs = tcx.lift(&substs).unwrap_or_else(|| {
|
||||||
tcx.intern_substs(&[])
|
tcx.intern_substs(&[])
|
||||||
});
|
});
|
||||||
let bounds = item_predicates.instantiate(tcx, substs);
|
let bounds = predicates_of.instantiate(tcx, substs);
|
||||||
|
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
let mut is_sized = false;
|
let mut is_sized = false;
|
||||||
|
|
|
@ -42,7 +42,7 @@ use std::fmt;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax_pos::{DUMMY_SP, MultiSpan, Span};
|
use syntax_pos::{MultiSpan, Span};
|
||||||
use errors::DiagnosticBuilder;
|
use errors::DiagnosticBuilder;
|
||||||
|
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
|
@ -63,7 +63,7 @@ pub type LoanDataFlow<'a, 'tcx> = DataFlowContext<'a, 'tcx, LoanDataFlowOperator
|
||||||
|
|
||||||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||||
tcx.visit_all_bodies_in_krate(|body_owner_def_id, _body_id| {
|
tcx.visit_all_bodies_in_krate(|body_owner_def_id, _body_id| {
|
||||||
ty::queries::borrowck::get(tcx, DUMMY_SP, body_owner_def_id);
|
tcx.borrowck(body_owner_def_id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId) {
|
||||||
let owner_id = tcx.hir.as_local_node_id(owner_def_id).unwrap();
|
let owner_id = tcx.hir.as_local_node_id(owner_def_id).unwrap();
|
||||||
let body_id = tcx.hir.body_owned_by(owner_id);
|
let body_id = tcx.hir.body_owned_by(owner_id);
|
||||||
let attributes = tcx.get_attrs(owner_def_id);
|
let attributes = tcx.get_attrs(owner_def_id);
|
||||||
let tables = tcx.item_tables(owner_def_id);
|
let tables = tcx.typeck_tables_of(owner_def_id);
|
||||||
|
|
||||||
let mut bccx = &mut BorrowckCtxt {
|
let mut bccx = &mut BorrowckCtxt {
|
||||||
tcx: tcx,
|
tcx: tcx,
|
||||||
|
@ -169,7 +169,7 @@ pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>(
|
||||||
{
|
{
|
||||||
let owner_id = tcx.hir.body_owner(body_id);
|
let owner_id = tcx.hir.body_owner(body_id);
|
||||||
let owner_def_id = tcx.hir.local_def_id(owner_id);
|
let owner_def_id = tcx.hir.local_def_id(owner_id);
|
||||||
let tables = tcx.item_tables(owner_def_id);
|
let tables = tcx.typeck_tables_of(owner_def_id);
|
||||||
|
|
||||||
let mut bccx = BorrowckCtxt {
|
let mut bccx = BorrowckCtxt {
|
||||||
tcx: tcx,
|
tcx: tcx,
|
||||||
|
|
|
@ -27,7 +27,7 @@ use rustc::util::nodemap::DefIdMap;
|
||||||
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use rustc::hir::{self, Expr};
|
use rustc::hir::{self, Expr};
|
||||||
use syntax_pos::{Span, DUMMY_SP};
|
use syntax_pos::Span;
|
||||||
|
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>,
|
||||||
match cx.tables.qpath_def(qpath, e.id) {
|
match cx.tables.qpath_def(qpath, e.id) {
|
||||||
Def::Const(def_id) |
|
Def::Const(def_id) |
|
||||||
Def::AssociatedConst(def_id) => {
|
Def::AssociatedConst(def_id) => {
|
||||||
match ty::queries::const_eval::get(tcx, e.span, (def_id, substs)) {
|
match tcx.at(e.span).const_eval((def_id, substs)) {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(ConstEvalErr { kind: TypeckError, .. }) => {
|
Err(ConstEvalErr { kind: TypeckError, .. }) => {
|
||||||
signal!(e, TypeckError);
|
signal!(e, TypeckError);
|
||||||
|
@ -376,7 +376,7 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>,
|
||||||
debug!("const call({:?})", call_args);
|
debug!("const call({:?})", call_args);
|
||||||
let callee_cx = ConstContext {
|
let callee_cx = ConstContext {
|
||||||
tcx: tcx,
|
tcx: tcx,
|
||||||
tables: tcx.item_tables(def_id),
|
tables: tcx.typeck_tables_of(def_id),
|
||||||
substs: substs,
|
substs: substs,
|
||||||
fn_args: Some(call_args)
|
fn_args: Some(call_args)
|
||||||
};
|
};
|
||||||
|
@ -607,7 +607,7 @@ fn cast_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
Float(f) => cast_const_float(tcx, f, ty),
|
Float(f) => cast_const_float(tcx, f, ty),
|
||||||
Char(c) => cast_const_int(tcx, U32(c as u32), ty),
|
Char(c) => cast_const_int(tcx, U32(c as u32), ty),
|
||||||
Variant(v) => {
|
Variant(v) => {
|
||||||
let adt = tcx.lookup_adt_def(tcx.parent_def_id(v).unwrap());
|
let adt = tcx.adt_def(tcx.parent_def_id(v).unwrap());
|
||||||
let idx = adt.variant_index_with_id(v);
|
let idx = adt.variant_index_with_id(v);
|
||||||
cast_const_int(tcx, adt.discriminant_for_variant(tcx, idx), ty)
|
cast_const_int(tcx, adt.discriminant_for_variant(tcx, idx), ty)
|
||||||
}
|
}
|
||||||
|
@ -767,13 +767,13 @@ fn const_eval<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
let cx = ConstContext {
|
let cx = ConstContext {
|
||||||
tcx,
|
tcx,
|
||||||
tables: tcx.item_tables(def_id),
|
tables: tcx.typeck_tables_of(def_id),
|
||||||
substs: substs,
|
substs: substs,
|
||||||
fn_args: None
|
fn_args: None
|
||||||
};
|
};
|
||||||
|
|
||||||
let body = if let Some(id) = tcx.hir.as_local_node_id(def_id) {
|
let body = if let Some(id) = tcx.hir.as_local_node_id(def_id) {
|
||||||
ty::queries::mir_const_qualif::get(tcx, DUMMY_SP, def_id);
|
tcx.mir_const_qualif(def_id);
|
||||||
tcx.hir.body(tcx.hir.body_owned_by(id))
|
tcx.hir.body(tcx.hir.body_owned_by(id))
|
||||||
} else {
|
} else {
|
||||||
tcx.sess.cstore.item_body(tcx, def_id)
|
tcx.sess.cstore.item_body(tcx, def_id)
|
||||||
|
|
|
@ -547,7 +547,7 @@ impl<'a, 'gcx, 'tcx> PatternContext<'a, 'gcx, 'tcx> {
|
||||||
match def {
|
match def {
|
||||||
Def::Variant(variant_id) | Def::VariantCtor(variant_id, ..) => {
|
Def::Variant(variant_id) | Def::VariantCtor(variant_id, ..) => {
|
||||||
let enum_id = self.tcx.parent_def_id(variant_id).unwrap();
|
let enum_id = self.tcx.parent_def_id(variant_id).unwrap();
|
||||||
let adt_def = self.tcx.lookup_adt_def(enum_id);
|
let adt_def = self.tcx.adt_def(enum_id);
|
||||||
if adt_def.variants.len() > 1 {
|
if adt_def.variants.len() > 1 {
|
||||||
let substs = match ty.sty {
|
let substs = match ty.sty {
|
||||||
TypeVariants::TyAdt(_, substs) => substs,
|
TypeVariants::TyAdt(_, substs) => substs,
|
||||||
|
@ -591,7 +591,7 @@ impl<'a, 'gcx, 'tcx> PatternContext<'a, 'gcx, 'tcx> {
|
||||||
Some((def_id, _substs)) => {
|
Some((def_id, _substs)) => {
|
||||||
// Enter the inlined constant's tables temporarily.
|
// Enter the inlined constant's tables temporarily.
|
||||||
let old_tables = self.tables;
|
let old_tables = self.tables;
|
||||||
self.tables = tcx.item_tables(def_id);
|
self.tables = tcx.typeck_tables_of(def_id);
|
||||||
let body = if let Some(id) = tcx.hir.as_local_node_id(def_id) {
|
let body = if let Some(id) = tcx.hir.as_local_node_id(def_id) {
|
||||||
tcx.hir.body(tcx.hir.body_owned_by(id))
|
tcx.hir.body(tcx.hir.body_owned_by(id))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -118,7 +118,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
|
||||||
hir::ItemStruct(..) |
|
hir::ItemStruct(..) |
|
||||||
hir::ItemUnion(..) => {
|
hir::ItemUnion(..) => {
|
||||||
let def_id = cx.tcx.hir.local_def_id(it.id);
|
let def_id = cx.tcx.hir.local_def_id(it.id);
|
||||||
self.check_heap_type(cx, it.span, cx.tcx.item_type(def_id))
|
self.check_heap_type(cx, it.span, cx.tcx.type_of(def_id))
|
||||||
}
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
|
||||||
for struct_field in struct_def.fields() {
|
for struct_field in struct_def.fields() {
|
||||||
let def_id = cx.tcx.hir.local_def_id(struct_field.id);
|
let def_id = cx.tcx.hir.local_def_id(struct_field.id);
|
||||||
self.check_heap_type(cx, struct_field.span,
|
self.check_heap_type(cx, struct_field.span,
|
||||||
cx.tcx.item_type(def_id));
|
cx.tcx.type_of(def_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
|
@ -504,21 +504,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
|
||||||
if ast_generics.is_parameterized() {
|
if ast_generics.is_parameterized() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let def = cx.tcx.lookup_adt_def(cx.tcx.hir.local_def_id(item.id));
|
let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id));
|
||||||
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
|
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
|
||||||
}
|
}
|
||||||
hir::ItemUnion(_, ref ast_generics) => {
|
hir::ItemUnion(_, ref ast_generics) => {
|
||||||
if ast_generics.is_parameterized() {
|
if ast_generics.is_parameterized() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let def = cx.tcx.lookup_adt_def(cx.tcx.hir.local_def_id(item.id));
|
let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id));
|
||||||
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
|
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
|
||||||
}
|
}
|
||||||
hir::ItemEnum(_, ref ast_generics) => {
|
hir::ItemEnum(_, ref ast_generics) => {
|
||||||
if ast_generics.is_parameterized() {
|
if ast_generics.is_parameterized() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let def = cx.tcx.lookup_adt_def(cx.tcx.hir.local_def_id(item.id));
|
let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id));
|
||||||
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
|
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
|
||||||
}
|
}
|
||||||
_ => return,
|
_ => return,
|
||||||
|
@ -582,10 +582,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
|
||||||
};
|
};
|
||||||
|
|
||||||
if self.impling_types.is_none() {
|
if self.impling_types.is_none() {
|
||||||
let debug_def = cx.tcx.lookup_trait_def(debug);
|
let debug_def = cx.tcx.trait_def(debug);
|
||||||
let mut impls = NodeSet();
|
let mut impls = NodeSet();
|
||||||
debug_def.for_each_impl(cx.tcx, |d| {
|
debug_def.for_each_impl(cx.tcx, |d| {
|
||||||
if let Some(ty_def) = cx.tcx.item_type(d).ty_to_def_id() {
|
if let Some(ty_def) = cx.tcx.type_of(d).ty_to_def_id() {
|
||||||
if let Some(node_id) = cx.tcx.hir.as_local_node_id(ty_def) {
|
if let Some(node_id) = cx.tcx.hir.as_local_node_id(ty_def) {
|
||||||
impls.insert(node_id);
|
impls.insert(node_id);
|
||||||
}
|
}
|
||||||
|
@ -1094,7 +1094,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn def_id_is_transmute(cx: &LateContext, def_id: DefId) -> bool {
|
fn def_id_is_transmute(cx: &LateContext, def_id: DefId) -> bool {
|
||||||
match cx.tcx.item_type(def_id).sty {
|
match cx.tcx.type_of(def_id).sty {
|
||||||
ty::TyFnDef(.., bfty) if bfty.abi() == RustIntrinsic => (),
|
ty::TyFnDef(.., bfty) if bfty.abi() == RustIntrinsic => (),
|
||||||
_ => return false,
|
_ => return false,
|
||||||
}
|
}
|
||||||
|
@ -1151,7 +1151,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
|
||||||
if let hir::ItemUnion(ref vdata, _) = item.node {
|
if let hir::ItemUnion(ref vdata, _) = item.node {
|
||||||
let param_env = &ty::ParameterEnvironment::for_item(ctx.tcx, item.id);
|
let param_env = &ty::ParameterEnvironment::for_item(ctx.tcx, item.id);
|
||||||
for field in vdata.fields() {
|
for field in vdata.fields() {
|
||||||
let field_ty = ctx.tcx.item_type(ctx.tcx.hir.local_def_id(field.id));
|
let field_ty = ctx.tcx.type_of(ctx.tcx.hir.local_def_id(field.id));
|
||||||
if field_ty.needs_drop(ctx.tcx, param_env) {
|
if field_ty.needs_drop(ctx.tcx, param_env) {
|
||||||
ctx.span_lint(UNIONS_WITH_DROP_FIELDS,
|
ctx.span_lint(UNIONS_WITH_DROP_FIELDS,
|
||||||
field.span,
|
field.span,
|
||||||
|
|
|
@ -660,7 +660,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
||||||
|
|
||||||
fn check_foreign_fn(&mut self, id: ast::NodeId, decl: &hir::FnDecl) {
|
fn check_foreign_fn(&mut self, id: ast::NodeId, decl: &hir::FnDecl) {
|
||||||
let def_id = self.cx.tcx.hir.local_def_id(id);
|
let def_id = self.cx.tcx.hir.local_def_id(id);
|
||||||
let sig = self.cx.tcx.item_type(def_id).fn_sig();
|
let sig = self.cx.tcx.type_of(def_id).fn_sig();
|
||||||
let sig = self.cx.tcx.erase_late_bound_regions(&sig);
|
let sig = self.cx.tcx.erase_late_bound_regions(&sig);
|
||||||
|
|
||||||
for (input_ty, input_hir) in sig.inputs().iter().zip(&decl.inputs) {
|
for (input_ty, input_hir) in sig.inputs().iter().zip(&decl.inputs) {
|
||||||
|
@ -677,7 +677,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
||||||
|
|
||||||
fn check_foreign_static(&mut self, id: ast::NodeId, span: Span) {
|
fn check_foreign_static(&mut self, id: ast::NodeId, span: Span) {
|
||||||
let def_id = self.cx.tcx.hir.local_def_id(id);
|
let def_id = self.cx.tcx.hir.local_def_id(id);
|
||||||
let ty = self.cx.tcx.item_type(def_id);
|
let ty = self.cx.tcx.type_of(def_id);
|
||||||
self.check_type_for_ffi_and_report_errors(span, ty);
|
self.check_type_for_ffi_and_report_errors(span, ty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -724,7 +724,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
|
||||||
if let hir::ItemEnum(ref enum_definition, ref gens) = it.node {
|
if let hir::ItemEnum(ref enum_definition, ref gens) = it.node {
|
||||||
if gens.ty_params.is_empty() {
|
if gens.ty_params.is_empty() {
|
||||||
// sizes only make sense for non-generic types
|
// sizes only make sense for non-generic types
|
||||||
let t = cx.tcx.item_type(cx.tcx.hir.local_def_id(it.id));
|
let t = cx.tcx.type_of(cx.tcx.hir.local_def_id(it.id));
|
||||||
let layout = cx.tcx.infer_ctxt((), Reveal::All).enter(|infcx| {
|
let layout = cx.tcx.infer_ctxt((), Reveal::All).enter(|infcx| {
|
||||||
let ty = cx.tcx.erase_regions(&t);
|
let ty = cx.tcx.erase_regions(&t);
|
||||||
ty.layout(&infcx).unwrap_or_else(|e| {
|
ty.layout(&infcx).unwrap_or_else(|e| {
|
||||||
|
|
|
@ -69,10 +69,10 @@ macro_rules! provide {
|
||||||
}
|
}
|
||||||
|
|
||||||
provide! { <'tcx> tcx, def_id, cdata
|
provide! { <'tcx> tcx, def_id, cdata
|
||||||
ty => { cdata.get_type(def_id.index, tcx) }
|
type_of => { cdata.get_type(def_id.index, tcx) }
|
||||||
generics => { tcx.alloc_generics(cdata.get_generics(def_id.index)) }
|
generics_of => { tcx.alloc_generics(cdata.get_generics(def_id.index)) }
|
||||||
predicates => { cdata.get_predicates(def_id.index, tcx) }
|
predicates_of => { cdata.get_predicates(def_id.index, tcx) }
|
||||||
super_predicates => { cdata.get_super_predicates(def_id.index, tcx) }
|
super_predicates_of => { cdata.get_super_predicates(def_id.index, tcx) }
|
||||||
trait_def => {
|
trait_def => {
|
||||||
tcx.alloc_trait_def(cdata.get_trait_def(def_id.index))
|
tcx.alloc_trait_def(cdata.get_trait_def(def_id.index))
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ provide! { <'tcx> tcx, def_id, cdata
|
||||||
let _ = cdata;
|
let _ = cdata;
|
||||||
tcx.calculate_dtor(def_id, &mut |_,_| Ok(()))
|
tcx.calculate_dtor(def_id, &mut |_,_| Ok(()))
|
||||||
}
|
}
|
||||||
variances => { Rc::new(cdata.get_item_variances(def_id.index)) }
|
variances_of => { Rc::new(cdata.get_item_variances(def_id.index)) }
|
||||||
associated_item_def_ids => {
|
associated_item_def_ids => {
|
||||||
let mut result = vec![];
|
let mut result = vec![];
|
||||||
cdata.each_child_of_item(def_id.index, |child| result.push(child.def.def_id()));
|
cdata.each_child_of_item(def_id.index, |child| result.push(child.def.def_id()));
|
||||||
|
@ -108,7 +108,7 @@ provide! { <'tcx> tcx, def_id, cdata
|
||||||
mir
|
mir
|
||||||
}
|
}
|
||||||
mir_const_qualif => { cdata.mir_const_qualif(def_id.index) }
|
mir_const_qualif => { cdata.mir_const_qualif(def_id.index) }
|
||||||
typeck_tables => { cdata.item_body_tables(def_id.index, tcx) }
|
typeck_tables_of => { cdata.item_body_tables(def_id.index, tcx) }
|
||||||
closure_kind => { cdata.closure_kind(def_id.index) }
|
closure_kind => { cdata.closure_kind(def_id.index) }
|
||||||
closure_type => { cdata.closure_ty(def_id.index, tcx) }
|
closure_type => { cdata.closure_ty(def_id.index, tcx) }
|
||||||
inherent_impls => { Rc::new(cdata.get_inherent_implementations_for_type(def_id.index)) }
|
inherent_impls => { Rc::new(cdata.get_inherent_implementations_for_type(def_id.index)) }
|
||||||
|
|
|
@ -367,7 +367,7 @@ impl<'a, 'tcx> SpecializedDecoder<&'tcx ty::Slice<Ty<'tcx>>> for DecodeContext<'
|
||||||
impl<'a, 'tcx> SpecializedDecoder<&'tcx ty::AdtDef> for DecodeContext<'a, 'tcx> {
|
impl<'a, 'tcx> SpecializedDecoder<&'tcx ty::AdtDef> for DecodeContext<'a, 'tcx> {
|
||||||
fn specialized_decode(&mut self) -> Result<&'tcx ty::AdtDef, Self::Error> {
|
fn specialized_decode(&mut self) -> Result<&'tcx ty::AdtDef, Self::Error> {
|
||||||
let def_id = DefId::decode(self)?;
|
let def_id = DefId::decode(self)?;
|
||||||
Ok(self.tcx().lookup_adt_def(def_id))
|
Ok(self.tcx().adt_def(def_id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ use syntax::ast::{self, CRATE_NODE_ID};
|
||||||
use syntax::codemap::Spanned;
|
use syntax::codemap::Spanned;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::symbol::Symbol;
|
use syntax::symbol::Symbol;
|
||||||
use syntax_pos::{self, DUMMY_SP};
|
use syntax_pos;
|
||||||
|
|
||||||
use rustc::hir::{self, PatKind};
|
use rustc::hir::{self, PatKind};
|
||||||
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
||||||
|
@ -242,12 +242,12 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
fn encode_item_variances(&mut self, def_id: DefId) -> LazySeq<ty::Variance> {
|
fn encode_item_variances(&mut self, def_id: DefId) -> LazySeq<ty::Variance> {
|
||||||
debug!("EntryBuilder::encode_item_variances({:?})", def_id);
|
debug!("EntryBuilder::encode_item_variances({:?})", def_id);
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
self.lazy_seq_from_slice(&tcx.item_variances(def_id))
|
self.lazy_seq_from_slice(&tcx.variances_of(def_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_item_type(&mut self, def_id: DefId) -> Lazy<Ty<'tcx>> {
|
fn encode_item_type(&mut self, def_id: DefId) -> Lazy<Ty<'tcx>> {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
let ty = tcx.item_type(def_id);
|
let ty = tcx.type_of(def_id);
|
||||||
debug!("EntryBuilder::encode_item_type({:?}) => {:?}", def_id, ty);
|
debug!("EntryBuilder::encode_item_type({:?}) => {:?}", def_id, ty);
|
||||||
self.lazy(&ty)
|
self.lazy(&ty)
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
(enum_did, Untracked(index)): (DefId, Untracked<usize>))
|
(enum_did, Untracked(index)): (DefId, Untracked<usize>))
|
||||||
-> Entry<'tcx> {
|
-> Entry<'tcx> {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
let def = tcx.lookup_adt_def(enum_did);
|
let def = tcx.adt_def(enum_did);
|
||||||
let variant = &def.variants[index];
|
let variant = &def.variants[index];
|
||||||
let def_id = variant.did;
|
let def_id = variant.did;
|
||||||
debug!("EntryBuilder::encode_enum_variant_info({:?})", def_id);
|
debug!("EntryBuilder::encode_enum_variant_info({:?})", def_id);
|
||||||
|
@ -341,7 +341,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
|
|
||||||
impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
|
impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
|
||||||
fn encode_fields(&mut self, adt_def_id: DefId) {
|
fn encode_fields(&mut self, adt_def_id: DefId) {
|
||||||
let def = self.tcx.lookup_adt_def(adt_def_id);
|
let def = self.tcx.adt_def(adt_def_id);
|
||||||
for (variant_index, variant) in def.variants.iter().enumerate() {
|
for (variant_index, variant) in def.variants.iter().enumerate() {
|
||||||
for (field_index, field) in variant.fields.iter().enumerate() {
|
for (field_index, field) in variant.fields.iter().enumerate() {
|
||||||
self.record(field.did,
|
self.record(field.did,
|
||||||
|
@ -365,7 +365,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
usize)>))
|
usize)>))
|
||||||
-> Entry<'tcx> {
|
-> Entry<'tcx> {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
let variant = &tcx.lookup_adt_def(adt_def_id).variants[variant_index];
|
let variant = &tcx.adt_def(adt_def_id).variants[variant_index];
|
||||||
let field = &variant.fields[field_index];
|
let field = &variant.fields[field_index];
|
||||||
|
|
||||||
let def_id = field.did;
|
let def_id = field.did;
|
||||||
|
@ -397,7 +397,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
fn encode_struct_ctor(&mut self, (adt_def_id, def_id): (DefId, DefId)) -> Entry<'tcx> {
|
fn encode_struct_ctor(&mut self, (adt_def_id, def_id): (DefId, DefId)) -> Entry<'tcx> {
|
||||||
debug!("EntryBuilder::encode_struct_ctor({:?})", def_id);
|
debug!("EntryBuilder::encode_struct_ctor({:?})", def_id);
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
let variant = tcx.lookup_adt_def(adt_def_id).struct_variant();
|
let variant = tcx.adt_def(adt_def_id).struct_variant();
|
||||||
|
|
||||||
let data = VariantData {
|
let data = VariantData {
|
||||||
ctor_kind: variant.ctor_kind,
|
ctor_kind: variant.ctor_kind,
|
||||||
|
@ -439,13 +439,13 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
fn encode_generics(&mut self, def_id: DefId) -> Lazy<ty::Generics> {
|
fn encode_generics(&mut self, def_id: DefId) -> Lazy<ty::Generics> {
|
||||||
debug!("EntryBuilder::encode_generics({:?})", def_id);
|
debug!("EntryBuilder::encode_generics({:?})", def_id);
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
self.lazy(tcx.item_generics(def_id))
|
self.lazy(tcx.generics_of(def_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_predicates(&mut self, def_id: DefId) -> Lazy<ty::GenericPredicates<'tcx>> {
|
fn encode_predicates(&mut self, def_id: DefId) -> Lazy<ty::GenericPredicates<'tcx>> {
|
||||||
debug!("EntryBuilder::encode_predicates({:?})", def_id);
|
debug!("EntryBuilder::encode_predicates({:?})", def_id);
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
self.lazy(&tcx.item_predicates(def_id))
|
self.lazy(&tcx.predicates_of(def_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_info_for_trait_item(&mut self, def_id: DefId) -> Entry<'tcx> {
|
fn encode_info_for_trait_item(&mut self, def_id: DefId) -> Entry<'tcx> {
|
||||||
|
@ -547,7 +547,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
let kind = match impl_item.kind {
|
let kind = match impl_item.kind {
|
||||||
ty::AssociatedKind::Const => {
|
ty::AssociatedKind::Const => {
|
||||||
EntryKind::AssociatedConst(container,
|
EntryKind::AssociatedConst(container,
|
||||||
ty::queries::mir_const_qualif::get(self.tcx, ast_item.span, def_id))
|
self.tcx.at(ast_item.span).mir_const_qualif(def_id))
|
||||||
}
|
}
|
||||||
ty::AssociatedKind::Method => {
|
ty::AssociatedKind::Method => {
|
||||||
let fn_data = if let hir::ImplItemKind::Method(ref sig, body) = ast_item.node {
|
let fn_data = if let hir::ImplItemKind::Method(ref sig, body) = ast_item.node {
|
||||||
|
@ -570,7 +570,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
let (ast, mir) = if let hir::ImplItemKind::Const(_, body) = ast_item.node {
|
let (ast, mir) = if let hir::ImplItemKind::Const(_, body) = ast_item.node {
|
||||||
(Some(body), true)
|
(Some(body), true)
|
||||||
} else if let hir::ImplItemKind::Method(ref sig, body) = ast_item.node {
|
} else if let hir::ImplItemKind::Method(ref sig, body) = ast_item.node {
|
||||||
let generics = self.tcx.item_generics(def_id);
|
let generics = self.tcx.generics_of(def_id);
|
||||||
let types = generics.parent_types as usize + generics.types.len();
|
let types = generics.parent_types as usize + generics.types.len();
|
||||||
let needs_inline = types > 0 || attr::requests_inline(&ast_item.attrs);
|
let needs_inline = types > 0 || attr::requests_inline(&ast_item.attrs);
|
||||||
let is_const_fn = sig.constness == hir::Constness::Const;
|
let is_const_fn = sig.constness == hir::Constness::Const;
|
||||||
|
@ -656,7 +656,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
hir::ItemStatic(_, hir::MutMutable, _) => EntryKind::MutStatic,
|
hir::ItemStatic(_, hir::MutMutable, _) => EntryKind::MutStatic,
|
||||||
hir::ItemStatic(_, hir::MutImmutable, _) => EntryKind::ImmStatic,
|
hir::ItemStatic(_, hir::MutImmutable, _) => EntryKind::ImmStatic,
|
||||||
hir::ItemConst(..) => {
|
hir::ItemConst(..) => {
|
||||||
EntryKind::Const(ty::queries::mir_const_qualif::get(tcx, item.span, def_id))
|
EntryKind::Const(tcx.at(item.span).mir_const_qualif(def_id))
|
||||||
}
|
}
|
||||||
hir::ItemFn(_, _, constness, .., body) => {
|
hir::ItemFn(_, _, constness, .., body) => {
|
||||||
let data = FnData {
|
let data = FnData {
|
||||||
|
@ -674,7 +674,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
hir::ItemTy(..) => EntryKind::Type,
|
hir::ItemTy(..) => EntryKind::Type,
|
||||||
hir::ItemEnum(..) => EntryKind::Enum(get_repr_options(&tcx, def_id)),
|
hir::ItemEnum(..) => EntryKind::Enum(get_repr_options(&tcx, def_id)),
|
||||||
hir::ItemStruct(ref struct_def, _) => {
|
hir::ItemStruct(ref struct_def, _) => {
|
||||||
let variant = tcx.lookup_adt_def(def_id).struct_variant();
|
let variant = tcx.adt_def(def_id).struct_variant();
|
||||||
|
|
||||||
// Encode def_ids for each field and method
|
// Encode def_ids for each field and method
|
||||||
// for methods, write all the stuff get_trait_method
|
// for methods, write all the stuff get_trait_method
|
||||||
|
@ -694,7 +694,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
}), repr_options)
|
}), repr_options)
|
||||||
}
|
}
|
||||||
hir::ItemUnion(..) => {
|
hir::ItemUnion(..) => {
|
||||||
let variant = tcx.lookup_adt_def(def_id).struct_variant();
|
let variant = tcx.adt_def(def_id).struct_variant();
|
||||||
let repr_options = get_repr_options(&tcx, def_id);
|
let repr_options = get_repr_options(&tcx, def_id);
|
||||||
|
|
||||||
EntryKind::Union(self.lazy(&VariantData {
|
EntryKind::Union(self.lazy(&VariantData {
|
||||||
|
@ -716,7 +716,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
hir::ItemImpl(_, polarity, ..) => {
|
hir::ItemImpl(_, polarity, ..) => {
|
||||||
let trait_ref = tcx.impl_trait_ref(def_id);
|
let trait_ref = tcx.impl_trait_ref(def_id);
|
||||||
let parent = if let Some(trait_ref) = trait_ref {
|
let parent = if let Some(trait_ref) = trait_ref {
|
||||||
let trait_def = tcx.lookup_trait_def(trait_ref.def_id);
|
let trait_def = tcx.trait_def(trait_ref.def_id);
|
||||||
trait_def.ancestors(def_id).skip(1).next().and_then(|node| {
|
trait_def.ancestors(def_id).skip(1).next().and_then(|node| {
|
||||||
match node {
|
match node {
|
||||||
specialization_graph::Node::Impl(parent) => Some(parent),
|
specialization_graph::Node::Impl(parent) => Some(parent),
|
||||||
|
@ -732,7 +732,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
let coerce_unsized_info =
|
let coerce_unsized_info =
|
||||||
trait_ref.and_then(|t| {
|
trait_ref.and_then(|t| {
|
||||||
if Some(t.def_id) == tcx.lang_items.coerce_unsized_trait() {
|
if Some(t.def_id) == tcx.lang_items.coerce_unsized_trait() {
|
||||||
Some(ty::queries::coerce_unsized_info::get(tcx, item.span, def_id))
|
Some(tcx.at(item.span).coerce_unsized_info(def_id))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -748,12 +748,12 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
EntryKind::Impl(self.lazy(&data))
|
EntryKind::Impl(self.lazy(&data))
|
||||||
}
|
}
|
||||||
hir::ItemTrait(..) => {
|
hir::ItemTrait(..) => {
|
||||||
let trait_def = tcx.lookup_trait_def(def_id);
|
let trait_def = tcx.trait_def(def_id);
|
||||||
let data = TraitData {
|
let data = TraitData {
|
||||||
unsafety: trait_def.unsafety,
|
unsafety: trait_def.unsafety,
|
||||||
paren_sugar: trait_def.paren_sugar,
|
paren_sugar: trait_def.paren_sugar,
|
||||||
has_default_impl: tcx.trait_has_default_impl(def_id),
|
has_default_impl: tcx.trait_has_default_impl(def_id),
|
||||||
super_predicates: self.lazy(&tcx.item_super_predicates(def_id)),
|
super_predicates: self.lazy(&tcx.super_predicates_of(def_id)),
|
||||||
};
|
};
|
||||||
|
|
||||||
EntryKind::Trait(self.lazy(&data))
|
EntryKind::Trait(self.lazy(&data))
|
||||||
|
@ -774,7 +774,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
.map(|foreign_item| tcx.hir.local_def_id(foreign_item.id).index))
|
.map(|foreign_item| tcx.hir.local_def_id(foreign_item.id).index))
|
||||||
}
|
}
|
||||||
hir::ItemEnum(..) => {
|
hir::ItemEnum(..) => {
|
||||||
let def = self.tcx.lookup_adt_def(def_id);
|
let def = self.tcx.adt_def(def_id);
|
||||||
self.lazy_seq(def.variants.iter().map(|v| {
|
self.lazy_seq(def.variants.iter().map(|v| {
|
||||||
assert!(v.did.is_local());
|
assert!(v.did.is_local());
|
||||||
v.did.index
|
v.did.index
|
||||||
|
@ -782,7 +782,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
}
|
}
|
||||||
hir::ItemStruct(..) |
|
hir::ItemStruct(..) |
|
||||||
hir::ItemUnion(..) => {
|
hir::ItemUnion(..) => {
|
||||||
let def = self.tcx.lookup_adt_def(def_id);
|
let def = self.tcx.adt_def(def_id);
|
||||||
self.lazy_seq(def.struct_variant().fields.iter().map(|f| {
|
self.lazy_seq(def.struct_variant().fields.iter().map(|f| {
|
||||||
assert!(f.did.is_local());
|
assert!(f.did.is_local());
|
||||||
f.did.index
|
f.did.index
|
||||||
|
@ -919,7 +919,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
|
||||||
hir::ItemEnum(..) => {
|
hir::ItemEnum(..) => {
|
||||||
self.encode_fields(def_id);
|
self.encode_fields(def_id);
|
||||||
|
|
||||||
let def = self.tcx.lookup_adt_def(def_id);
|
let def = self.tcx.adt_def(def_id);
|
||||||
for (i, variant) in def.variants.iter().enumerate() {
|
for (i, variant) in def.variants.iter().enumerate() {
|
||||||
self.record(variant.did,
|
self.record(variant.did,
|
||||||
EntryBuilder::encode_enum_variant_info,
|
EntryBuilder::encode_enum_variant_info,
|
||||||
|
@ -1169,7 +1169,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
|
||||||
let body = tcx.hir.body_owned_by(id);
|
let body = tcx.hir.body_owned_by(id);
|
||||||
|
|
||||||
Entry {
|
Entry {
|
||||||
kind: EntryKind::Const(ty::queries::mir_const_qualif::get(tcx, DUMMY_SP, def_id)),
|
kind: EntryKind::Const(tcx.mir_const_qualif(def_id)),
|
||||||
visibility: self.lazy(&ty::Visibility::Public),
|
visibility: self.lazy(&ty::Visibility::Public),
|
||||||
span: self.lazy(&tcx.def_span(def_id)),
|
span: self.lazy(&tcx.def_span(def_id)),
|
||||||
attributes: LazySeq::empty(),
|
attributes: LazySeq::empty(),
|
||||||
|
@ -1539,7 +1539,7 @@ pub fn encode_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_repr_options<'a, 'tcx, 'gcx>(tcx: &TyCtxt<'a, 'tcx, 'gcx>, did: DefId) -> ReprOptions {
|
pub fn get_repr_options<'a, 'tcx, 'gcx>(tcx: &TyCtxt<'a, 'tcx, 'gcx>, did: DefId) -> ReprOptions {
|
||||||
let ty = tcx.item_type(did);
|
let ty = tcx.type_of(did);
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
ty::TyAdt(ref def, _) => return def.repr,
|
ty::TyAdt(ref def, _) => return def.repr,
|
||||||
_ => bug!("{} is not an ADT", ty),
|
_ => bug!("{} is not an ADT", ty),
|
||||||
|
|
|
@ -784,7 +784,7 @@ fn build_free<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||||
TerminatorKind::Call {
|
TerminatorKind::Call {
|
||||||
func: Operand::Constant(Constant {
|
func: Operand::Constant(Constant {
|
||||||
span: data.span,
|
span: data.span,
|
||||||
ty: tcx.item_type(free_func).subst(tcx, substs),
|
ty: tcx.type_of(free_func).subst(tcx, substs),
|
||||||
literal: Literal::Value {
|
literal: Literal::Value {
|
||||||
value: ConstVal::Function(free_func, substs),
|
value: ConstVal::Function(free_func, substs),
|
||||||
}
|
}
|
||||||
|
|
|
@ -594,7 +594,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
||||||
let c = &cx.tcx.hir.body(count).value;
|
let c = &cx.tcx.hir.body(count).value;
|
||||||
let def_id = cx.tcx.hir.body_owner_def_id(count);
|
let def_id = cx.tcx.hir.body_owner_def_id(count);
|
||||||
let substs = Substs::empty();
|
let substs = Substs::empty();
|
||||||
let count = match ty::queries::const_eval::get(cx.tcx, c.span, (def_id, substs)) {
|
let count = match cx.tcx.at(c.span).const_eval((def_id, substs)) {
|
||||||
Ok(ConstVal::Integral(ConstInt::Usize(u))) => u,
|
Ok(ConstVal::Integral(ConstInt::Usize(u))) => u,
|
||||||
Ok(other) => bug!("constant evaluation of repeat count yielded {:?}", other),
|
Ok(other) => bug!("constant evaluation of repeat count yielded {:?}", other),
|
||||||
Err(s) => cx.fatal_const_eval_err(&s, c.span, "expression")
|
Err(s) => cx.fatal_const_eval_err(&s, c.span, "expression")
|
||||||
|
|
|
@ -140,7 +140,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
|
||||||
let substs = self.tcx.mk_substs_trait(self_ty, params);
|
let substs = self.tcx.mk_substs_trait(self_ty, params);
|
||||||
for item in self.tcx.associated_items(trait_def_id) {
|
for item in self.tcx.associated_items(trait_def_id) {
|
||||||
if item.kind == ty::AssociatedKind::Method && item.name == method_name {
|
if item.kind == ty::AssociatedKind::Method && item.name == method_name {
|
||||||
let method_ty = self.tcx.item_type(item.def_id);
|
let method_ty = self.tcx.type_of(item.def_id);
|
||||||
let method_ty = method_ty.subst(self.tcx, substs);
|
let method_ty = method_ty.subst(self.tcx, substs);
|
||||||
return (method_ty,
|
return (method_ty,
|
||||||
Literal::Value {
|
Literal::Value {
|
||||||
|
|
|
@ -139,7 +139,7 @@ fn build_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||||
// types/lifetimes replaced)
|
// types/lifetimes replaced)
|
||||||
let fn_sig = cx.tables().liberated_fn_sigs[&id].clone();
|
let fn_sig = cx.tables().liberated_fn_sigs[&id].clone();
|
||||||
|
|
||||||
let ty = tcx.item_type(tcx.hir.local_def_id(id));
|
let ty = tcx.type_of(tcx.hir.local_def_id(id));
|
||||||
let mut abi = fn_sig.abi;
|
let mut abi = fn_sig.abi;
|
||||||
let implicit_argument = if let ty::TyClosure(..) = ty.sty {
|
let implicit_argument = if let ty::TyClosure(..) = ty.sty {
|
||||||
// HACK(eddyb) Avoid having RustCall on closures,
|
// HACK(eddyb) Avoid having RustCall on closures,
|
||||||
|
|
|
@ -167,7 +167,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
} else {
|
} else {
|
||||||
param_env.free_substs
|
param_env.free_substs
|
||||||
};
|
};
|
||||||
let fn_ty = tcx.item_type(def_id).subst(tcx, substs);
|
let fn_ty = tcx.type_of(def_id).subst(tcx, substs);
|
||||||
let sig = tcx.erase_late_bound_regions(&fn_ty.fn_sig());
|
let sig = tcx.erase_late_bound_regions(&fn_ty.fn_sig());
|
||||||
let span = tcx.def_span(def_id);
|
let span = tcx.def_span(def_id);
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ fn build_call_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
call_kind={:?}, untuple_args={:?})",
|
call_kind={:?}, untuple_args={:?})",
|
||||||
def_id, rcvr_adjustment, call_kind, untuple_args);
|
def_id, rcvr_adjustment, call_kind, untuple_args);
|
||||||
|
|
||||||
let fn_ty = tcx.item_type(def_id).subst(tcx, param_env.free_substs);
|
let fn_ty = tcx.type_of(def_id).subst(tcx, param_env.free_substs);
|
||||||
let sig = tcx.erase_late_bound_regions(&fn_ty.fn_sig());
|
let sig = tcx.erase_late_bound_regions(&fn_ty.fn_sig());
|
||||||
let span = tcx.def_span(def_id);
|
let span = tcx.def_span(def_id);
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ fn build_call_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
CallKind::Direct(def_id) => (
|
CallKind::Direct(def_id) => (
|
||||||
Operand::Constant(Constant {
|
Operand::Constant(Constant {
|
||||||
span: span,
|
span: span,
|
||||||
ty: tcx.item_type(def_id).subst(tcx, param_env.free_substs),
|
ty: tcx.type_of(def_id).subst(tcx, param_env.free_substs),
|
||||||
literal: Literal::Value {
|
literal: Literal::Value {
|
||||||
value: ConstVal::Function(def_id, param_env.free_substs),
|
value: ConstVal::Function(def_id, param_env.free_substs),
|
||||||
},
|
},
|
||||||
|
@ -422,7 +422,7 @@ pub fn build_adt_ctor<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>,
|
||||||
{
|
{
|
||||||
let tcx = infcx.tcx;
|
let tcx = infcx.tcx;
|
||||||
let def_id = tcx.hir.local_def_id(ctor_id);
|
let def_id = tcx.hir.local_def_id(ctor_id);
|
||||||
let sig = match tcx.item_type(def_id).sty {
|
let sig = match tcx.type_of(def_id).sty {
|
||||||
ty::TyFnDef(_, _, fty) => tcx.no_late_bound_regions(&fty)
|
ty::TyFnDef(_, _, fty) => tcx.no_late_bound_regions(&fty)
|
||||||
.expect("LBR in ADT constructor signature"),
|
.expect("LBR in ADT constructor signature"),
|
||||||
_ => bug!("unexpected type for ctor {:?}", def_id)
|
_ => bug!("unexpected type for ctor {:?}", def_id)
|
||||||
|
|
|
@ -258,7 +258,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
|
||||||
let mut span = None;
|
let mut span = None;
|
||||||
|
|
||||||
self.tcx
|
self.tcx
|
||||||
.lookup_trait_def(drop_trait_id)
|
.trait_def(drop_trait_id)
|
||||||
.for_each_relevant_impl(self.tcx, self.mir.return_ty, |impl_did| {
|
.for_each_relevant_impl(self.tcx, self.mir.return_ty, |impl_did| {
|
||||||
self.tcx.hir
|
self.tcx.hir
|
||||||
.as_local_node_id(impl_did)
|
.as_local_node_id(impl_did)
|
||||||
|
@ -573,9 +573,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
|
||||||
if substs.types().next().is_some() {
|
if substs.types().next().is_some() {
|
||||||
self.add_type(constant.ty);
|
self.add_type(constant.ty);
|
||||||
} else {
|
} else {
|
||||||
let bits = ty::queries::mir_const_qualif::get(self.tcx,
|
let bits = self.tcx.at(constant.span).mir_const_qualif(def_id);
|
||||||
constant.span,
|
|
||||||
def_id);
|
|
||||||
|
|
||||||
let qualif = Qualif::from_bits(bits).expect("invalid mir_const_qualif");
|
let qualif = Qualif::from_bits(bits).expect("invalid mir_const_qualif");
|
||||||
self.add(qualif);
|
self.add(qualif);
|
||||||
|
@ -959,7 +957,7 @@ impl<'tcx> MirMapPass<'tcx> for QualifyAndPromoteConstants {
|
||||||
let src = MirSource::from_node(tcx, id);
|
let src = MirSource::from_node(tcx, id);
|
||||||
|
|
||||||
if let MirSource::Const(_) = src {
|
if let MirSource::Const(_) = src {
|
||||||
ty::queries::mir_const_qualif::get(tcx, DUMMY_SP, def_id);
|
tcx.mir_const_qualif(def_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
||||||
Lvalue::Local(index) => LvalueTy::Ty { ty: self.mir.local_decls[index].ty },
|
Lvalue::Local(index) => LvalueTy::Ty { ty: self.mir.local_decls[index].ty },
|
||||||
Lvalue::Static(box Static { def_id, ty: sty }) => {
|
Lvalue::Static(box Static { def_id, ty: sty }) => {
|
||||||
let sty = self.sanitize_type(lvalue, sty);
|
let sty = self.sanitize_type(lvalue, sty);
|
||||||
let ty = self.tcx().item_type(def_id);
|
let ty = self.tcx().type_of(def_id);
|
||||||
let ty = self.cx.normalize(&ty);
|
let ty = self.cx.normalize(&ty);
|
||||||
if let Err(terr) = self.cx.eq_types(self.last_span, ty, sty) {
|
if let Err(terr) = self.cx.eq_types(self.last_span, ty, sty) {
|
||||||
span_mirbug!(
|
span_mirbug!(
|
||||||
|
|
|
@ -130,7 +130,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckCrateVisitor<'a, 'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let outer_tables = self.tables;
|
let outer_tables = self.tables;
|
||||||
self.tables = self.tcx.item_tables(self.tcx.hir.local_def_id(item_id));
|
self.tables = self.tcx.typeck_tables_of(self.tcx.hir.local_def_id(item_id));
|
||||||
|
|
||||||
let body = self.tcx.hir.body(body_id);
|
let body = self.tcx.hir.body(body_id);
|
||||||
if !self.in_fn {
|
if !self.in_fn {
|
||||||
|
|
|
@ -37,7 +37,7 @@ use rustc::ty::fold::TypeVisitor;
|
||||||
use rustc::ty::maps::Providers;
|
use rustc::ty::maps::Providers;
|
||||||
use rustc::util::nodemap::NodeSet;
|
use rustc::util::nodemap::NodeSet;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax_pos::{DUMMY_SP, Span};
|
use syntax_pos::Span;
|
||||||
|
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::mem::replace;
|
use std::mem::replace;
|
||||||
|
@ -87,7 +87,7 @@ struct ReachEverythingInTheInterfaceVisitor<'b, 'a: 'b, 'tcx: 'a> {
|
||||||
|
|
||||||
impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> {
|
impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> {
|
||||||
fn item_ty_level(&self, item_def_id: DefId) -> Option<AccessLevel> {
|
fn item_ty_level(&self, item_def_id: DefId) -> Option<AccessLevel> {
|
||||||
let ty_def_id = match self.tcx.item_type(item_def_id).sty {
|
let ty_def_id = match self.tcx.type_of(item_def_id).sty {
|
||||||
ty::TyAdt(adt, _) => adt.did,
|
ty::TyAdt(adt, _) => adt.did,
|
||||||
ty::TyDynamic(ref obj, ..) if obj.principal().is_some() =>
|
ty::TyDynamic(ref obj, ..) if obj.principal().is_some() =>
|
||||||
obj.principal().unwrap().def_id(),
|
obj.principal().unwrap().def_id(),
|
||||||
|
@ -235,7 +235,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||||
hir::ItemConst(..) | hir::ItemStatic(..) |
|
hir::ItemConst(..) | hir::ItemStatic(..) |
|
||||||
hir::ItemFn(..) | hir::ItemTy(..) => {
|
hir::ItemFn(..) | hir::ItemTy(..) => {
|
||||||
if item_level.is_some() {
|
if item_level.is_some() {
|
||||||
self.reach(item.id).generics().predicates().item_type();
|
self.reach(item.id).generics().predicates().ty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ItemTrait(.., ref trait_item_refs) => {
|
hir::ItemTrait(.., ref trait_item_refs) => {
|
||||||
|
@ -250,7 +250,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||||
!trait_item_ref.defaultness.has_value() {
|
!trait_item_ref.defaultness.has_value() {
|
||||||
// No type to visit.
|
// No type to visit.
|
||||||
} else {
|
} else {
|
||||||
reach.item_type();
|
reach.ty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||||
for impl_item_ref in impl_item_refs {
|
for impl_item_ref in impl_item_refs {
|
||||||
let id = impl_item_ref.id.node_id;
|
let id = impl_item_ref.id.node_id;
|
||||||
if trait_ref.is_some() || self.get(id).is_some() {
|
if trait_ref.is_some() || self.get(id).is_some() {
|
||||||
self.reach(id).generics().predicates().item_type();
|
self.reach(id).generics().predicates().ty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||||
for variant in &def.variants {
|
for variant in &def.variants {
|
||||||
if self.get(variant.node.data.id()).is_some() {
|
if self.get(variant.node.data.id()).is_some() {
|
||||||
for field in variant.node.data.fields() {
|
for field in variant.node.data.fields() {
|
||||||
self.reach(field.id).item_type();
|
self.reach(field.id).ty();
|
||||||
}
|
}
|
||||||
// Corner case: if the variant is reachable, but its
|
// Corner case: if the variant is reachable, but its
|
||||||
// enum is not, make the enum reachable as well.
|
// enum is not, make the enum reachable as well.
|
||||||
|
@ -289,7 +289,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||||
hir::ItemForeignMod(ref foreign_mod) => {
|
hir::ItemForeignMod(ref foreign_mod) => {
|
||||||
for foreign_item in &foreign_mod.items {
|
for foreign_item in &foreign_mod.items {
|
||||||
if self.get(foreign_item.id).is_some() {
|
if self.get(foreign_item.id).is_some() {
|
||||||
self.reach(foreign_item.id).generics().predicates().item_type();
|
self.reach(foreign_item.id).generics().predicates().ty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||||
self.reach(item.id).generics().predicates();
|
self.reach(item.id).generics().predicates();
|
||||||
for field in struct_def.fields() {
|
for field in struct_def.fields() {
|
||||||
if self.get(field.id).is_some() {
|
if self.get(field.id).is_some() {
|
||||||
self.reach(field.id).item_type();
|
self.reach(field.id).ty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||||
if let hir::TyImplTrait(..) = ty.node {
|
if let hir::TyImplTrait(..) = ty.node {
|
||||||
if self.get(ty.id).is_some() {
|
if self.get(ty.id).is_some() {
|
||||||
// Reach the (potentially private) type and the API being exposed.
|
// Reach the (potentially private) type and the API being exposed.
|
||||||
self.reach(ty.id).item_type().predicates();
|
self.reach(ty.id).ty().predicates();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,21 +360,21 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||||
|
|
||||||
impl<'b, 'a, 'tcx> ReachEverythingInTheInterfaceVisitor<'b, 'a, 'tcx> {
|
impl<'b, 'a, 'tcx> ReachEverythingInTheInterfaceVisitor<'b, 'a, 'tcx> {
|
||||||
fn generics(&mut self) -> &mut Self {
|
fn generics(&mut self) -> &mut Self {
|
||||||
for def in &self.ev.tcx.item_generics(self.item_def_id).types {
|
for def in &self.ev.tcx.generics_of(self.item_def_id).types {
|
||||||
if def.has_default {
|
if def.has_default {
|
||||||
self.ev.tcx.item_type(def.def_id).visit_with(self);
|
self.ev.tcx.type_of(def.def_id).visit_with(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn predicates(&mut self) -> &mut Self {
|
fn predicates(&mut self) -> &mut Self {
|
||||||
self.ev.tcx.item_predicates(self.item_def_id).visit_with(self);
|
self.ev.tcx.predicates_of(self.item_def_id).visit_with(self);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_type(&mut self) -> &mut Self {
|
fn ty(&mut self) -> &mut Self {
|
||||||
self.ev.tcx.item_type(self.item_def_id).visit_with(self);
|
self.ev.tcx.type_of(self.item_def_id).visit_with(self);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -868,21 +868,21 @@ struct SearchInterfaceForPrivateItemsVisitor<'a, 'tcx: 'a> {
|
||||||
|
|
||||||
impl<'a, 'tcx: 'a> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> {
|
impl<'a, 'tcx: 'a> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> {
|
||||||
fn generics(&mut self) -> &mut Self {
|
fn generics(&mut self) -> &mut Self {
|
||||||
for def in &self.tcx.item_generics(self.item_def_id).types {
|
for def in &self.tcx.generics_of(self.item_def_id).types {
|
||||||
if def.has_default {
|
if def.has_default {
|
||||||
self.tcx.item_type(def.def_id).visit_with(self);
|
self.tcx.type_of(def.def_id).visit_with(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn predicates(&mut self) -> &mut Self {
|
fn predicates(&mut self) -> &mut Self {
|
||||||
self.tcx.item_predicates(self.item_def_id).visit_with(self);
|
self.tcx.predicates_of(self.item_def_id).visit_with(self);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_type(&mut self) -> &mut Self {
|
fn ty(&mut self) -> &mut Self {
|
||||||
self.tcx.item_type(self.item_def_id).visit_with(self);
|
self.tcx.type_of(self.item_def_id).visit_with(self);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1048,7 +1048,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||||
// Subitems of these items have inherited publicity
|
// Subitems of these items have inherited publicity
|
||||||
hir::ItemConst(..) | hir::ItemStatic(..) | hir::ItemFn(..) |
|
hir::ItemConst(..) | hir::ItemStatic(..) | hir::ItemFn(..) |
|
||||||
hir::ItemTy(..) => {
|
hir::ItemTy(..) => {
|
||||||
self.check(item.id, item_visibility).generics().predicates().item_type();
|
self.check(item.id, item_visibility).generics().predicates().ty();
|
||||||
|
|
||||||
// Recurse for e.g. `impl Trait` (see `visit_ty`).
|
// Recurse for e.g. `impl Trait` (see `visit_ty`).
|
||||||
self.inner_visibility = item_visibility;
|
self.inner_visibility = item_visibility;
|
||||||
|
@ -1065,7 +1065,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||||
!trait_item_ref.defaultness.has_value() {
|
!trait_item_ref.defaultness.has_value() {
|
||||||
// No type to visit.
|
// No type to visit.
|
||||||
} else {
|
} else {
|
||||||
check.item_type();
|
check.ty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1074,7 +1074,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||||
|
|
||||||
for variant in &def.variants {
|
for variant in &def.variants {
|
||||||
for field in variant.node.data.fields() {
|
for field in variant.node.data.fields() {
|
||||||
self.check(field.id, item_visibility).item_type();
|
self.check(field.id, item_visibility).ty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1082,7 +1082,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||||
hir::ItemForeignMod(ref foreign_mod) => {
|
hir::ItemForeignMod(ref foreign_mod) => {
|
||||||
for foreign_item in &foreign_mod.items {
|
for foreign_item in &foreign_mod.items {
|
||||||
let vis = ty::Visibility::from_hir(&foreign_item.vis, item.id, tcx);
|
let vis = ty::Visibility::from_hir(&foreign_item.vis, item.id, tcx);
|
||||||
self.check(foreign_item.id, vis).generics().predicates().item_type();
|
self.check(foreign_item.id, vis).generics().predicates().ty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Subitems of structs and unions have their own publicity
|
// Subitems of structs and unions have their own publicity
|
||||||
|
@ -1092,7 +1092,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||||
|
|
||||||
for field in struct_def.fields() {
|
for field in struct_def.fields() {
|
||||||
let field_visibility = ty::Visibility::from_hir(&field.vis, item.id, tcx);
|
let field_visibility = ty::Visibility::from_hir(&field.vis, item.id, tcx);
|
||||||
self.check(field.id, min(item_visibility, field_visibility)).item_type();
|
self.check(field.id, min(item_visibility, field_visibility)).ty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// The interface is empty
|
// The interface is empty
|
||||||
|
@ -1101,7 +1101,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||||
// Subitems of inherent impls have their own publicity
|
// Subitems of inherent impls have their own publicity
|
||||||
hir::ItemImpl(.., None, _, ref impl_item_refs) => {
|
hir::ItemImpl(.., None, _, ref impl_item_refs) => {
|
||||||
let ty_vis =
|
let ty_vis =
|
||||||
self.check(item.id, ty::Visibility::Invisible).item_type().min_visibility;
|
self.check(item.id, ty::Visibility::Invisible).ty().min_visibility;
|
||||||
self.check(item.id, ty_vis).generics().predicates();
|
self.check(item.id, ty_vis).generics().predicates();
|
||||||
|
|
||||||
for impl_item_ref in impl_item_refs {
|
for impl_item_ref in impl_item_refs {
|
||||||
|
@ -1109,7 +1109,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||||
let impl_item_vis =
|
let impl_item_vis =
|
||||||
ty::Visibility::from_hir(&impl_item.vis, item.id, tcx);
|
ty::Visibility::from_hir(&impl_item.vis, item.id, tcx);
|
||||||
self.check(impl_item.id, min(impl_item_vis, ty_vis))
|
self.check(impl_item.id, min(impl_item_vis, ty_vis))
|
||||||
.generics().predicates().item_type();
|
.generics().predicates().ty();
|
||||||
|
|
||||||
// Recurse for e.g. `impl Trait` (see `visit_ty`).
|
// Recurse for e.g. `impl Trait` (see `visit_ty`).
|
||||||
self.inner_visibility = impl_item_vis;
|
self.inner_visibility = impl_item_vis;
|
||||||
|
@ -1120,11 +1120,11 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||||
// Subitems of trait impls have inherited publicity
|
// Subitems of trait impls have inherited publicity
|
||||||
hir::ItemImpl(.., Some(_), _, ref impl_item_refs) => {
|
hir::ItemImpl(.., Some(_), _, ref impl_item_refs) => {
|
||||||
let vis = self.check(item.id, ty::Visibility::Invisible)
|
let vis = self.check(item.id, ty::Visibility::Invisible)
|
||||||
.item_type().impl_trait_ref().min_visibility;
|
.ty().impl_trait_ref().min_visibility;
|
||||||
self.check(item.id, vis).generics().predicates();
|
self.check(item.id, vis).generics().predicates();
|
||||||
for impl_item_ref in impl_item_refs {
|
for impl_item_ref in impl_item_refs {
|
||||||
let impl_item = self.tcx.hir.impl_item(impl_item_ref.id);
|
let impl_item = self.tcx.hir.impl_item(impl_item_ref.id);
|
||||||
self.check(impl_item.id, vis).generics().predicates().item_type();
|
self.check(impl_item.id, vis).generics().predicates().ty();
|
||||||
|
|
||||||
// Recurse for e.g. `impl Trait` (see `visit_ty`).
|
// Recurse for e.g. `impl Trait` (see `visit_ty`).
|
||||||
self.inner_visibility = vis;
|
self.inner_visibility = vis;
|
||||||
|
@ -1144,7 +1144,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||||
// e.g. `impl Iterator<Item=T>` has two predicates,
|
// e.g. `impl Iterator<Item=T>` has two predicates,
|
||||||
// `X: Iterator` and `<X as Iterator>::Item == T`,
|
// `X: Iterator` and `<X as Iterator>::Item == T`,
|
||||||
// where `X` is the `impl Iterator<Item=T>` itself,
|
// where `X` is the `impl Iterator<Item=T>` itself,
|
||||||
// stored in `item_predicates`, not in the `Ty` itself.
|
// stored in `predicates_of`, not in the `Ty` itself.
|
||||||
self.check(ty.id, self.inner_visibility).predicates();
|
self.check(ty.id, self.inner_visibility).predicates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1166,7 +1166,7 @@ pub fn provide(providers: &mut Providers) {
|
||||||
|
|
||||||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Rc<AccessLevels> {
|
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Rc<AccessLevels> {
|
||||||
tcx.dep_graph.with_ignore(|| { // FIXME
|
tcx.dep_graph.with_ignore(|| { // FIXME
|
||||||
ty::queries::privacy_access_levels::get(tcx, DUMMY_SP, LOCAL_CRATE)
|
tcx.privacy_access_levels(LOCAL_CRATE)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
|
||||||
where F: FnOnce(&mut DumpVisitor<'l, 'tcx, 'll, D>)
|
where F: FnOnce(&mut DumpVisitor<'l, 'tcx, 'll, D>)
|
||||||
{
|
{
|
||||||
let item_def_id = self.tcx.hir.local_def_id(item_id);
|
let item_def_id = self.tcx.hir.local_def_id(item_id);
|
||||||
match self.tcx.maps.typeck_tables.borrow().get(&item_def_id) {
|
match self.tcx.maps.typeck_tables_of.borrow().get(&item_def_id) {
|
||||||
Some(tables) => {
|
Some(tables) => {
|
||||||
let old_tables = self.save_ctxt.tables;
|
let old_tables = self.save_ctxt.tables;
|
||||||
self.save_ctxt.tables = tables;
|
self.save_ctxt.tables = tables;
|
||||||
|
|
|
@ -341,7 +341,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||||
let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon);
|
let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon);
|
||||||
filter!(self.span_utils, sub_span, field.span, None);
|
filter!(self.span_utils, sub_span, field.span, None);
|
||||||
let def_id = self.tcx.hir.local_def_id(field.id);
|
let def_id = self.tcx.hir.local_def_id(field.id);
|
||||||
let typ = self.tcx.item_type(def_id).to_string();
|
let typ = self.tcx.type_of(def_id).to_string();
|
||||||
|
|
||||||
let span = field.span;
|
let span = field.span;
|
||||||
let text = self.span_utils.snippet(field.span);
|
let text = self.span_utils.snippet(field.span);
|
||||||
|
|
|
@ -232,7 +232,7 @@ pub fn symbol_name<'a, 'tcx>(instance: Instance<'tcx>,
|
||||||
match key.disambiguated_data.data {
|
match key.disambiguated_data.data {
|
||||||
DefPathData::TypeNs(_) |
|
DefPathData::TypeNs(_) |
|
||||||
DefPathData::ValueNs(_) => {
|
DefPathData::ValueNs(_) => {
|
||||||
instance_ty = tcx.item_type(ty_def_id);
|
instance_ty = tcx.type_of(ty_def_id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
@ -1041,7 +1041,7 @@ pub fn find_exported_symbols(tcx: TyCtxt, reachable: &NodeSet) -> NodeSet {
|
||||||
hir_map::NodeImplItem(&hir::ImplItem {
|
hir_map::NodeImplItem(&hir::ImplItem {
|
||||||
node: hir::ImplItemKind::Method(..), .. }) => {
|
node: hir::ImplItemKind::Method(..), .. }) => {
|
||||||
let def_id = tcx.hir.local_def_id(id);
|
let def_id = tcx.hir.local_def_id(id);
|
||||||
let generics = tcx.item_generics(def_id);
|
let generics = tcx.generics_of(def_id);
|
||||||
let attributes = tcx.get_attrs(def_id);
|
let attributes = tcx.get_attrs(def_id);
|
||||||
(generics.parent_types == 0 && generics.types.is_empty()) &&
|
(generics.parent_types == 0 && generics.types.is_empty()) &&
|
||||||
// Functions marked with #[inline] are only ever translated
|
// Functions marked with #[inline] are only ever translated
|
||||||
|
|
|
@ -21,9 +21,8 @@ use declare;
|
||||||
use llvm::{self, ValueRef};
|
use llvm::{self, ValueRef};
|
||||||
use monomorphize::{self, Instance};
|
use monomorphize::{self, Instance};
|
||||||
use rustc::hir::def_id::DefId;
|
use rustc::hir::def_id::DefId;
|
||||||
use rustc::ty::{self, TypeFoldable};
|
use rustc::ty::TypeFoldable;
|
||||||
use rustc::ty::subst::Substs;
|
use rustc::ty::subst::Substs;
|
||||||
use syntax_pos::DUMMY_SP;
|
|
||||||
use trans_item::TransItem;
|
use trans_item::TransItem;
|
||||||
use type_of;
|
use type_of;
|
||||||
|
|
||||||
|
@ -105,7 +104,7 @@ pub fn get_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||||
// *in Rust code* may unwind. Foreign items like `extern "C" {
|
// *in Rust code* may unwind. Foreign items like `extern "C" {
|
||||||
// fn foo(); }` are assumed not to unwind **unless** they have
|
// fn foo(); }` are assumed not to unwind **unless** they have
|
||||||
// a `#[unwind]` attribute.
|
// a `#[unwind]` attribute.
|
||||||
if !ty::queries::is_foreign_item::get(tcx, DUMMY_SP, instance.def_id()) {
|
if !tcx.is_foreign_item(instance.def_id()) {
|
||||||
attributes::unwind(llfn, true);
|
attributes::unwind(llfn, true);
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMRustSetLinkage(llfn, llvm::Linkage::ExternalLinkage);
|
llvm::LLVMRustSetLinkage(llfn, llvm::Linkage::ExternalLinkage);
|
||||||
|
|
|
@ -935,14 +935,14 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(scx: &SharedCrateContext<'a, '
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !tcx.item_generics(method.def_id).types.is_empty() {
|
if !tcx.generics_of(method.def_id).types.is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let instance =
|
let instance =
|
||||||
monomorphize::resolve(scx, method.def_id, callee_substs);
|
monomorphize::resolve(scx, method.def_id, callee_substs);
|
||||||
|
|
||||||
let predicates = tcx.item_predicates(instance.def_id()).predicates
|
let predicates = tcx.predicates_of(instance.def_id()).predicates
|
||||||
.subst(tcx, instance.substs);
|
.subst(tcx, instance.substs);
|
||||||
if !traits::normalize_and_test_predicates(tcx, predicates) {
|
if !traits::normalize_and_test_predicates(tcx, predicates) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -563,7 +563,7 @@ pub fn def_ty<'a, 'tcx>(shared: &SharedCrateContext<'a, 'tcx>,
|
||||||
substs: &'tcx Substs<'tcx>)
|
substs: &'tcx Substs<'tcx>)
|
||||||
-> Ty<'tcx>
|
-> Ty<'tcx>
|
||||||
{
|
{
|
||||||
let ty = shared.tcx().item_type(def_id);
|
let ty = shared.tcx().type_of(def_id);
|
||||||
shared.tcx().trans_apply_param_substs(substs, &ty)
|
shared.tcx().trans_apply_param_substs(substs, &ty)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
|
|
||||||
// Get_template_parameters() will append a `<...>` clause to the function
|
// Get_template_parameters() will append a `<...>` clause to the function
|
||||||
// name if necessary.
|
// name if necessary.
|
||||||
let generics = cx.tcx().item_generics(fn_def_id);
|
let generics = cx.tcx().generics_of(fn_def_id);
|
||||||
let substs = instance.substs.truncate_to(cx.tcx(), generics);
|
let substs = instance.substs.truncate_to(cx.tcx(), generics);
|
||||||
let template_parameters = get_template_parameters(cx,
|
let template_parameters = get_template_parameters(cx,
|
||||||
&generics,
|
&generics,
|
||||||
|
@ -382,7 +382,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
|
|
||||||
fn get_type_parameter_names(cx: &CrateContext, generics: &ty::Generics) -> Vec<ast::Name> {
|
fn get_type_parameter_names(cx: &CrateContext, generics: &ty::Generics) -> Vec<ast::Name> {
|
||||||
let mut names = generics.parent.map_or(vec![], |def_id| {
|
let mut names = generics.parent.map_or(vec![], |def_id| {
|
||||||
get_type_parameter_names(cx, cx.tcx().item_generics(def_id))
|
get_type_parameter_names(cx, cx.tcx().generics_of(def_id))
|
||||||
});
|
});
|
||||||
names.extend(generics.types.iter().map(|param| param.name));
|
names.extend(generics.types.iter().map(|param| param.name));
|
||||||
names
|
names
|
||||||
|
|
|
@ -444,7 +444,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
|
||||||
},
|
},
|
||||||
ty::TyClosure(def_id, ref closure_substs) => {
|
ty::TyClosure(def_id, ref closure_substs) => {
|
||||||
self.push_def_path(def_id, output);
|
self.push_def_path(def_id, output);
|
||||||
let generics = self.tcx.item_generics(self.tcx.closure_base_def_id(def_id));
|
let generics = self.tcx.generics_of(self.tcx.closure_base_def_id(def_id));
|
||||||
let substs = closure_substs.substs.truncate_to(self.tcx, generics);
|
let substs = closure_substs.substs.truncate_to(self.tcx, generics);
|
||||||
self.push_type_params(substs, iter::empty(), output);
|
self.push_type_params(substs, iter::empty(), output);
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,7 +217,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||||
// If the type is parameterized by this region, then replace this
|
// If the type is parameterized by this region, then replace this
|
||||||
// region with the current anon region binding (in other words,
|
// region with the current anon region binding (in other words,
|
||||||
// whatever & would get replaced with).
|
// whatever & would get replaced with).
|
||||||
let decl_generics = tcx.item_generics(def_id);
|
let decl_generics = tcx.generics_of(def_id);
|
||||||
let expected_num_region_params = decl_generics.regions.len();
|
let expected_num_region_params = decl_generics.regions.len();
|
||||||
let supplied_num_region_params = lifetimes.len();
|
let supplied_num_region_params = lifetimes.len();
|
||||||
if expected_num_region_params != supplied_num_region_params {
|
if expected_num_region_params != supplied_num_region_params {
|
||||||
|
@ -238,7 +238,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||||
let is_object = self_ty.map_or(false, |ty| ty.sty == TRAIT_OBJECT_DUMMY_SELF);
|
let is_object = self_ty.map_or(false, |ty| ty.sty == TRAIT_OBJECT_DUMMY_SELF);
|
||||||
let default_needs_object_self = |p: &ty::TypeParameterDef| {
|
let default_needs_object_self = |p: &ty::TypeParameterDef| {
|
||||||
if is_object && p.has_default {
|
if is_object && p.has_default {
|
||||||
if ty::queries::ty::get(tcx, span, p.def_id).has_self_ty() {
|
if tcx.at(span).type_of(p.def_id).has_self_ty() {
|
||||||
// There is no suitable inference default for a type parameter
|
// There is no suitable inference default for a type parameter
|
||||||
// that references self, in an object type.
|
// that references self, in an object type.
|
||||||
return true;
|
return true;
|
||||||
|
@ -307,7 +307,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||||
// This is a default type parameter.
|
// This is a default type parameter.
|
||||||
self.normalize_ty(
|
self.normalize_ty(
|
||||||
span,
|
span,
|
||||||
ty::queries::ty::get(tcx, span, def.def_id)
|
tcx.at(span).type_of(def.def_id)
|
||||||
.subst_spanned(tcx, substs, Some(span))
|
.subst_spanned(tcx, substs, Some(span))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -458,7 +458,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||||
debug!("create_substs_for_ast_trait_ref(trait_segment={:?})",
|
debug!("create_substs_for_ast_trait_ref(trait_segment={:?})",
|
||||||
trait_segment);
|
trait_segment);
|
||||||
|
|
||||||
let trait_def = self.tcx().lookup_trait_def(trait_def_id);
|
let trait_def = self.tcx().trait_def(trait_def_id);
|
||||||
|
|
||||||
match trait_segment.parameters {
|
match trait_segment.parameters {
|
||||||
hir::AngleBracketedParameters(_) => {
|
hir::AngleBracketedParameters(_) => {
|
||||||
|
@ -600,7 +600,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||||
let substs = self.ast_path_substs_for_ty(span, did, item_segment);
|
let substs = self.ast_path_substs_for_ty(span, did, item_segment);
|
||||||
self.normalize_ty(
|
self.normalize_ty(
|
||||||
span,
|
span,
|
||||||
ty::queries::ty::get(self.tcx(), span, did).subst(self.tcx(), substs)
|
self.tcx().at(span).type_of(did).subst(self.tcx(), substs)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1014,7 +1014,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||||
let node_id = tcx.hir.as_local_node_id(did).unwrap();
|
let node_id = tcx.hir.as_local_node_id(did).unwrap();
|
||||||
let item_id = tcx.hir.get_parent_node(node_id);
|
let item_id = tcx.hir.get_parent_node(node_id);
|
||||||
let item_def_id = tcx.hir.local_def_id(item_id);
|
let item_def_id = tcx.hir.local_def_id(item_id);
|
||||||
let generics = tcx.item_generics(item_def_id);
|
let generics = tcx.generics_of(item_def_id);
|
||||||
let index = generics.type_param_to_index[&tcx.hir.local_def_id(node_id).index];
|
let index = generics.type_param_to_index[&tcx.hir.local_def_id(node_id).index];
|
||||||
tcx.mk_param(index, tcx.hir.name(node_id))
|
tcx.mk_param(index, tcx.hir.name(node_id))
|
||||||
}
|
}
|
||||||
|
@ -1024,7 +1024,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||||
assert_eq!(opt_self_ty, None);
|
assert_eq!(opt_self_ty, None);
|
||||||
self.prohibit_type_params(&path.segments);
|
self.prohibit_type_params(&path.segments);
|
||||||
|
|
||||||
let ty = ty::queries::ty::get(tcx, span, def_id);
|
let ty = tcx.at(span).type_of(def_id);
|
||||||
if let Some(free_substs) = self.get_free_substs() {
|
if let Some(free_substs) = self.get_free_substs() {
|
||||||
ty.subst(tcx, free_substs)
|
ty.subst(tcx, free_substs)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -180,10 +180,10 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
debug!("compare_impl_method: trait_to_skol_substs={:?}",
|
debug!("compare_impl_method: trait_to_skol_substs={:?}",
|
||||||
trait_to_skol_substs);
|
trait_to_skol_substs);
|
||||||
|
|
||||||
let impl_m_generics = tcx.item_generics(impl_m.def_id);
|
let impl_m_generics = tcx.generics_of(impl_m.def_id);
|
||||||
let trait_m_generics = tcx.item_generics(trait_m.def_id);
|
let trait_m_generics = tcx.generics_of(trait_m.def_id);
|
||||||
let impl_m_predicates = tcx.item_predicates(impl_m.def_id);
|
let impl_m_predicates = tcx.predicates_of(impl_m.def_id);
|
||||||
let trait_m_predicates = tcx.item_predicates(trait_m.def_id);
|
let trait_m_predicates = tcx.predicates_of(trait_m.def_id);
|
||||||
|
|
||||||
// Check region bounds.
|
// Check region bounds.
|
||||||
check_region_bounds_on_impl_method(tcx,
|
check_region_bounds_on_impl_method(tcx,
|
||||||
|
@ -199,7 +199,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
// environment. We can't just use `impl_env.caller_bounds`,
|
// environment. We can't just use `impl_env.caller_bounds`,
|
||||||
// however, because we want to replace all late-bound regions with
|
// however, because we want to replace all late-bound regions with
|
||||||
// region variables.
|
// region variables.
|
||||||
let impl_predicates = tcx.item_predicates(impl_m_predicates.parent.unwrap());
|
let impl_predicates = tcx.predicates_of(impl_m_predicates.parent.unwrap());
|
||||||
let mut hybrid_preds = impl_predicates.instantiate(tcx, impl_to_skol_substs);
|
let mut hybrid_preds = impl_predicates.instantiate(tcx, impl_to_skol_substs);
|
||||||
|
|
||||||
debug!("compare_impl_method: impl_bounds={:?}", hybrid_preds);
|
debug!("compare_impl_method: impl_bounds={:?}", hybrid_preds);
|
||||||
|
@ -261,7 +261,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
let tcx = infcx.tcx;
|
let tcx = infcx.tcx;
|
||||||
|
|
||||||
let m_sig = |method: &ty::AssociatedItem| {
|
let m_sig = |method: &ty::AssociatedItem| {
|
||||||
match tcx.item_type(method.def_id).sty {
|
match tcx.type_of(method.def_id).sty {
|
||||||
ty::TyFnDef(_, _, f) => f,
|
ty::TyFnDef(_, _, f) => f,
|
||||||
_ => bug!()
|
_ => bug!()
|
||||||
}
|
}
|
||||||
|
@ -509,7 +509,7 @@ fn compare_self_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
ty::ImplContainer(_) => impl_trait_ref.self_ty(),
|
ty::ImplContainer(_) => impl_trait_ref.self_ty(),
|
||||||
ty::TraitContainer(_) => tcx.mk_self_type()
|
ty::TraitContainer(_) => tcx.mk_self_type()
|
||||||
};
|
};
|
||||||
let method_ty = tcx.item_type(method.def_id);
|
let method_ty = tcx.type_of(method.def_id);
|
||||||
let self_arg_ty = *method_ty.fn_sig().input(0).skip_binder();
|
let self_arg_ty = *method_ty.fn_sig().input(0).skip_binder();
|
||||||
match ExplicitSelf::determine(untransformed_self_ty, self_arg_ty) {
|
match ExplicitSelf::determine(untransformed_self_ty, self_arg_ty) {
|
||||||
ExplicitSelf::ByValue => "self".to_string(),
|
ExplicitSelf::ByValue => "self".to_string(),
|
||||||
|
@ -567,8 +567,8 @@ fn compare_number_of_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
trait_m: &ty::AssociatedItem,
|
trait_m: &ty::AssociatedItem,
|
||||||
trait_item_span: Option<Span>)
|
trait_item_span: Option<Span>)
|
||||||
-> Result<(), ErrorReported> {
|
-> Result<(), ErrorReported> {
|
||||||
let impl_m_generics = tcx.item_generics(impl_m.def_id);
|
let impl_m_generics = tcx.generics_of(impl_m.def_id);
|
||||||
let trait_m_generics = tcx.item_generics(trait_m.def_id);
|
let trait_m_generics = tcx.generics_of(trait_m.def_id);
|
||||||
let num_impl_m_type_params = impl_m_generics.types.len();
|
let num_impl_m_type_params = impl_m_generics.types.len();
|
||||||
let num_trait_m_type_params = trait_m_generics.types.len();
|
let num_trait_m_type_params = trait_m_generics.types.len();
|
||||||
if num_impl_m_type_params != num_trait_m_type_params {
|
if num_impl_m_type_params != num_trait_m_type_params {
|
||||||
|
@ -637,7 +637,7 @@ fn compare_number_of_method_arguments<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
trait_item_span: Option<Span>)
|
trait_item_span: Option<Span>)
|
||||||
-> Result<(), ErrorReported> {
|
-> Result<(), ErrorReported> {
|
||||||
let m_fty = |method: &ty::AssociatedItem| {
|
let m_fty = |method: &ty::AssociatedItem| {
|
||||||
match tcx.item_type(method.def_id).sty {
|
match tcx.type_of(method.def_id).sty {
|
||||||
ty::TyFnDef(_, _, f) => f,
|
ty::TyFnDef(_, _, f) => f,
|
||||||
_ => bug!()
|
_ => bug!()
|
||||||
}
|
}
|
||||||
|
@ -750,8 +750,8 @@ pub fn compare_const_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
trait_to_skol_substs);
|
trait_to_skol_substs);
|
||||||
|
|
||||||
// Compute skolemized form of impl and trait const tys.
|
// Compute skolemized form of impl and trait const tys.
|
||||||
let impl_ty = tcx.item_type(impl_c.def_id).subst(tcx, impl_to_skol_substs);
|
let impl_ty = tcx.type_of(impl_c.def_id).subst(tcx, impl_to_skol_substs);
|
||||||
let trait_ty = tcx.item_type(trait_c.def_id).subst(tcx, trait_to_skol_substs);
|
let trait_ty = tcx.type_of(trait_c.def_id).subst(tcx, trait_to_skol_substs);
|
||||||
let mut cause = ObligationCause::misc(impl_c_span, impl_c_node_id);
|
let mut cause = ObligationCause::misc(impl_c_span, impl_c_node_id);
|
||||||
|
|
||||||
// There is no "body" here, so just pass dummy id.
|
// There is no "body" here, so just pass dummy id.
|
||||||
|
|
|
@ -135,7 +135,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
fn has_no_input_arg(&self, method: &AssociatedItem) -> bool {
|
fn has_no_input_arg(&self, method: &AssociatedItem) -> bool {
|
||||||
match method.def() {
|
match method.def() {
|
||||||
Def::Method(def_id) => {
|
Def::Method(def_id) => {
|
||||||
match self.tcx.item_type(def_id).sty {
|
match self.tcx.type_of(def_id).sty {
|
||||||
ty::TypeVariants::TyFnDef(_, _, sig) => {
|
ty::TypeVariants::TyFnDef(_, _, sig) => {
|
||||||
sig.inputs().skip_binder().len() == 1
|
sig.inputs().skip_binder().len() == 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,8 @@ use syntax_pos::Span;
|
||||||
pub fn check_drop_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
pub fn check_drop_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
drop_impl_did: DefId)
|
drop_impl_did: DefId)
|
||||||
-> Result<(), ErrorReported> {
|
-> Result<(), ErrorReported> {
|
||||||
let dtor_self_type = tcx.item_type(drop_impl_did);
|
let dtor_self_type = tcx.type_of(drop_impl_did);
|
||||||
let dtor_predicates = tcx.item_predicates(drop_impl_did);
|
let dtor_predicates = tcx.predicates_of(drop_impl_did);
|
||||||
match dtor_self_type.sty {
|
match dtor_self_type.sty {
|
||||||
ty::TyAdt(adt_def, self_to_impl_substs) => {
|
ty::TyAdt(adt_def, self_to_impl_substs) => {
|
||||||
ensure_drop_params_and_item_params_correspond(tcx,
|
ensure_drop_params_and_item_params_correspond(tcx,
|
||||||
|
@ -85,7 +85,7 @@ fn ensure_drop_params_and_item_params_correspond<'a, 'tcx>(
|
||||||
let tcx = infcx.tcx;
|
let tcx = infcx.tcx;
|
||||||
let mut fulfillment_cx = traits::FulfillmentContext::new();
|
let mut fulfillment_cx = traits::FulfillmentContext::new();
|
||||||
|
|
||||||
let named_type = tcx.item_type(self_type_did);
|
let named_type = tcx.type_of(self_type_did);
|
||||||
let named_type = named_type.subst(tcx, &infcx.parameter_environment.free_substs);
|
let named_type = named_type.subst(tcx, &infcx.parameter_environment.free_substs);
|
||||||
|
|
||||||
let drop_impl_span = tcx.def_span(drop_impl_did);
|
let drop_impl_span = tcx.def_span(drop_impl_did);
|
||||||
|
@ -175,7 +175,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'a, 'tcx>(
|
||||||
|
|
||||||
// We can assume the predicates attached to struct/enum definition
|
// We can assume the predicates attached to struct/enum definition
|
||||||
// hold.
|
// hold.
|
||||||
let generic_assumptions = tcx.item_predicates(self_type_did);
|
let generic_assumptions = tcx.predicates_of(self_type_did);
|
||||||
|
|
||||||
let assumptions_in_impl_context = generic_assumptions.instantiate(tcx, &self_to_impl_substs);
|
let assumptions_in_impl_context = generic_assumptions.instantiate(tcx, &self_to_impl_substs);
|
||||||
let assumptions_in_impl_context = assumptions_in_impl_context.predicates;
|
let assumptions_in_impl_context = assumptions_in_impl_context.predicates;
|
||||||
|
|
|
@ -46,7 +46,7 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
hir::Unsafety::Unsafe,
|
hir::Unsafety::Unsafe,
|
||||||
abi
|
abi
|
||||||
)));
|
)));
|
||||||
let i_n_tps = tcx.item_generics(def_id).types.len();
|
let i_n_tps = tcx.generics_of(def_id).types.len();
|
||||||
if i_n_tps != n_tps {
|
if i_n_tps != n_tps {
|
||||||
let span = match it.node {
|
let span = match it.node {
|
||||||
hir::ForeignItemFn(_, _, ref generics) => generics.span,
|
hir::ForeignItemFn(_, _, ref generics) => generics.span,
|
||||||
|
@ -64,7 +64,7 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
&ObligationCause::new(it.span,
|
&ObligationCause::new(it.span,
|
||||||
it.id,
|
it.id,
|
||||||
ObligationCauseCode::IntrinsicType),
|
ObligationCauseCode::IntrinsicType),
|
||||||
tcx.item_type(def_id),
|
tcx.type_of(def_id),
|
||||||
fty);
|
fty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ pub fn check_platform_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
};
|
};
|
||||||
|
|
||||||
let def_id = tcx.hir.local_def_id(it.id);
|
let def_id = tcx.hir.local_def_id(it.id);
|
||||||
let i_n_tps = tcx.item_generics(def_id).types.len();
|
let i_n_tps = tcx.generics_of(def_id).types.len();
|
||||||
let name = it.name.as_str();
|
let name = it.name.as_str();
|
||||||
|
|
||||||
let (n_tps, inputs, output) = match &*name {
|
let (n_tps, inputs, output) = match &*name {
|
||||||
|
@ -367,7 +367,7 @@ pub fn check_platform_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
let mut structural_to_nomimal = FxHashMap();
|
let mut structural_to_nomimal = FxHashMap();
|
||||||
|
|
||||||
let sig = tcx.item_type(def_id).fn_sig();
|
let sig = tcx.type_of(def_id).fn_sig();
|
||||||
let sig = tcx.no_late_bound_regions(&sig).unwrap();
|
let sig = tcx.no_late_bound_regions(&sig).unwrap();
|
||||||
if intr.inputs.len() != sig.inputs().len() {
|
if intr.inputs.len() != sig.inputs().len() {
|
||||||
span_err!(tcx.sess, it.span, E0444,
|
span_err!(tcx.sess, it.span, E0444,
|
||||||
|
|
|
@ -276,7 +276,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
||||||
// If they were not explicitly supplied, just construct fresh
|
// If they were not explicitly supplied, just construct fresh
|
||||||
// variables.
|
// variables.
|
||||||
let num_supplied_types = supplied_method_types.len();
|
let num_supplied_types = supplied_method_types.len();
|
||||||
let method_generics = self.tcx.item_generics(pick.item.def_id);
|
let method_generics = self.tcx.generics_of(pick.item.def_id);
|
||||||
let num_method_types = method_generics.types.len();
|
let num_method_types = method_generics.types.len();
|
||||||
|
|
||||||
if num_supplied_types > 0 && num_supplied_types != num_method_types {
|
if num_supplied_types > 0 && num_supplied_types != num_method_types {
|
||||||
|
@ -358,14 +358,14 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
||||||
// type/early-bound-regions substitutions performed. There can
|
// type/early-bound-regions substitutions performed. There can
|
||||||
// be no late-bound regions appearing here.
|
// be no late-bound regions appearing here.
|
||||||
let def_id = pick.item.def_id;
|
let def_id = pick.item.def_id;
|
||||||
let method_predicates = self.tcx.item_predicates(def_id)
|
let method_predicates = self.tcx.predicates_of(def_id)
|
||||||
.instantiate(self.tcx, all_substs);
|
.instantiate(self.tcx, all_substs);
|
||||||
let method_predicates = self.normalize_associated_types_in(self.span,
|
let method_predicates = self.normalize_associated_types_in(self.span,
|
||||||
&method_predicates);
|
&method_predicates);
|
||||||
|
|
||||||
debug!("method_predicates after subst = {:?}", method_predicates);
|
debug!("method_predicates after subst = {:?}", method_predicates);
|
||||||
|
|
||||||
let sig = self.tcx.item_type(def_id).fn_sig();
|
let sig = self.tcx.type_of(def_id).fn_sig();
|
||||||
|
|
||||||
// Instantiate late-bound regions and substitute the trait
|
// Instantiate late-bound regions and substitute the trait
|
||||||
// parameters into the method type to get the actual method type.
|
// parameters into the method type to get the actual method type.
|
||||||
|
|
|
@ -232,7 +232,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
let method_item = self.associated_item(trait_def_id, m_name).unwrap();
|
let method_item = self.associated_item(trait_def_id, m_name).unwrap();
|
||||||
let def_id = method_item.def_id;
|
let def_id = method_item.def_id;
|
||||||
let generics = tcx.item_generics(def_id);
|
let generics = tcx.generics_of(def_id);
|
||||||
assert_eq!(generics.types.len(), 0);
|
assert_eq!(generics.types.len(), 0);
|
||||||
assert_eq!(generics.regions.len(), 0);
|
assert_eq!(generics.regions.len(), 0);
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
// NB: Instantiate late-bound regions first so that
|
// NB: Instantiate late-bound regions first so that
|
||||||
// `instantiate_type_scheme` can normalize associated types that
|
// `instantiate_type_scheme` can normalize associated types that
|
||||||
// may reference those regions.
|
// may reference those regions.
|
||||||
let original_method_ty = tcx.item_type(def_id);
|
let original_method_ty = tcx.type_of(def_id);
|
||||||
let fn_sig = original_method_ty.fn_sig();
|
let fn_sig = original_method_ty.fn_sig();
|
||||||
let fn_sig = self.replace_late_bound_regions_with_fresh_var(span,
|
let fn_sig = self.replace_late_bound_regions_with_fresh_var(span,
|
||||||
infer::FnCall,
|
infer::FnCall,
|
||||||
|
@ -272,7 +272,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
//
|
//
|
||||||
// Note that as the method comes from a trait, it should not have
|
// Note that as the method comes from a trait, it should not have
|
||||||
// any late-bound regions appearing in its bounds.
|
// any late-bound regions appearing in its bounds.
|
||||||
let bounds = self.tcx.item_predicates(def_id).instantiate(self.tcx, substs);
|
let bounds = self.tcx.predicates_of(def_id).instantiate(self.tcx, substs);
|
||||||
let bounds = match self.normalize_associated_types_in_as_infer_ok(span, &bounds) {
|
let bounds = match self.normalize_associated_types_in_as_infer_ok(span, &bounds) {
|
||||||
InferOk { value, obligations: o } => {
|
InferOk { value, obligations: o } => {
|
||||||
obligations.extend(o);
|
obligations.extend(o);
|
||||||
|
|
|
@ -497,7 +497,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assemble_inherent_impl_candidates_for_type(&mut self, def_id: DefId) {
|
fn assemble_inherent_impl_candidates_for_type(&mut self, def_id: DefId) {
|
||||||
let impl_def_ids = ty::queries::inherent_impls::get(self.tcx, self.span, def_id);
|
let impl_def_ids = self.tcx.at(self.span).inherent_impls(def_id);
|
||||||
for &impl_def_id in impl_def_ids.iter() {
|
for &impl_def_id in impl_def_ids.iter() {
|
||||||
self.assemble_inherent_impl_probe(impl_def_id);
|
self.assemble_inherent_impl_probe(impl_def_id);
|
||||||
}
|
}
|
||||||
|
@ -661,7 +661,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||||
expected: ty::Ty<'tcx>) -> bool {
|
expected: ty::Ty<'tcx>) -> bool {
|
||||||
match method.def() {
|
match method.def() {
|
||||||
Def::Method(def_id) => {
|
Def::Method(def_id) => {
|
||||||
let fty = self.tcx.item_type(def_id).fn_sig();
|
let fty = self.tcx.type_of(def_id).fn_sig();
|
||||||
self.probe(|_| {
|
self.probe(|_| {
|
||||||
let substs = self.fresh_substs_for_item(self.span, method.def_id);
|
let substs = self.fresh_substs_for_item(self.span, method.def_id);
|
||||||
let output = fty.output().subst(self.tcx, substs);
|
let output = fty.output().subst(self.tcx, substs);
|
||||||
|
@ -706,7 +706,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||||
import_id: Option<ast::NodeId>,
|
import_id: Option<ast::NodeId>,
|
||||||
trait_def_id: DefId,
|
trait_def_id: DefId,
|
||||||
item: ty::AssociatedItem) {
|
item: ty::AssociatedItem) {
|
||||||
let trait_def = self.tcx.lookup_trait_def(trait_def_id);
|
let trait_def = self.tcx.trait_def(trait_def_id);
|
||||||
|
|
||||||
// FIXME(arielb1): can we use for_each_relevant_impl here?
|
// FIXME(arielb1): can we use for_each_relevant_impl here?
|
||||||
trait_def.for_each_impl(self.tcx, |impl_def_id| {
|
trait_def.for_each_impl(self.tcx, |impl_def_id| {
|
||||||
|
@ -756,7 +756,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let impl_type = self.tcx.item_type(impl_def_id);
|
let impl_type = self.tcx.type_of(impl_def_id);
|
||||||
let impl_simplified_type =
|
let impl_simplified_type =
|
||||||
match ty::fast_reject::simplify_type(self.tcx, impl_type, false) {
|
match ty::fast_reject::simplify_type(self.tcx, impl_type, false) {
|
||||||
Some(simplified_type) => simplified_type,
|
Some(simplified_type) => simplified_type,
|
||||||
|
@ -858,7 +858,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||||
def_id,
|
def_id,
|
||||||
substs);
|
substs);
|
||||||
|
|
||||||
let trait_predicates = self.tcx.item_predicates(def_id);
|
let trait_predicates = self.tcx.predicates_of(def_id);
|
||||||
let bounds = trait_predicates.instantiate(self.tcx, substs);
|
let bounds = trait_predicates.instantiate(self.tcx, substs);
|
||||||
let predicates = bounds.predicates;
|
let predicates = bounds.predicates;
|
||||||
debug!("assemble_projection_candidates: predicates={:?}",
|
debug!("assemble_projection_candidates: predicates={:?}",
|
||||||
|
@ -1167,7 +1167,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||||
let cause = traits::ObligationCause::misc(self.span, self.body_id);
|
let cause = traits::ObligationCause::misc(self.span, self.body_id);
|
||||||
|
|
||||||
// Check whether the impl imposes obligations we have to worry about.
|
// Check whether the impl imposes obligations we have to worry about.
|
||||||
let impl_bounds = self.tcx.item_predicates(impl_def_id);
|
let impl_bounds = self.tcx.predicates_of(impl_def_id);
|
||||||
let impl_bounds = impl_bounds.instantiate(self.tcx, substs);
|
let impl_bounds = impl_bounds.instantiate(self.tcx, substs);
|
||||||
let traits::Normalized { value: impl_bounds, obligations: norm_obligations } =
|
let traits::Normalized { value: impl_bounds, obligations: norm_obligations } =
|
||||||
traits::normalize(selcx, cause.clone(), &impl_bounds);
|
traits::normalize(selcx, cause.clone(), &impl_bounds);
|
||||||
|
@ -1276,7 +1276,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||||
impl_ty: Ty<'tcx>,
|
impl_ty: Ty<'tcx>,
|
||||||
substs: &Substs<'tcx>)
|
substs: &Substs<'tcx>)
|
||||||
-> Ty<'tcx> {
|
-> Ty<'tcx> {
|
||||||
let self_ty = self.tcx.item_type(method).fn_sig().input(0);
|
let self_ty = self.tcx.type_of(method).fn_sig().input(0);
|
||||||
debug!("xform_self_ty(impl_ty={:?}, self_ty={:?}, substs={:?})",
|
debug!("xform_self_ty(impl_ty={:?}, self_ty={:?}, substs={:?})",
|
||||||
impl_ty,
|
impl_ty,
|
||||||
self_ty,
|
self_ty,
|
||||||
|
@ -1289,7 +1289,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||||
// are given do not include type/lifetime parameters for the
|
// are given do not include type/lifetime parameters for the
|
||||||
// method yet. So create fresh variables here for those too,
|
// method yet. So create fresh variables here for those too,
|
||||||
// if there are any.
|
// if there are any.
|
||||||
let generics = self.tcx.item_generics(method);
|
let generics = self.tcx.generics_of(method);
|
||||||
assert_eq!(substs.types().count(), generics.parent_types as usize);
|
assert_eq!(substs.types().count(), generics.parent_types as usize);
|
||||||
assert_eq!(substs.regions().count(), generics.parent_regions as usize);
|
assert_eq!(substs.regions().count(), generics.parent_regions as usize);
|
||||||
|
|
||||||
|
@ -1323,7 +1323,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
/// Get the type of an impl and generate substitutions with placeholders.
|
/// Get the type of an impl and generate substitutions with placeholders.
|
||||||
fn impl_ty_and_substs(&self, impl_def_id: DefId) -> (Ty<'tcx>, &'tcx Substs<'tcx>) {
|
fn impl_ty_and_substs(&self, impl_def_id: DefId) -> (Ty<'tcx>, &'tcx Substs<'tcx>) {
|
||||||
let impl_ty = self.tcx.item_type(impl_def_id);
|
let impl_ty = self.tcx.type_of(impl_def_id);
|
||||||
|
|
||||||
let substs = Substs::for_item(self.tcx,
|
let substs = Substs::for_item(self.tcx,
|
||||||
impl_def_id,
|
impl_def_id,
|
||||||
|
|
|
@ -621,14 +621,14 @@ pub fn check_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> CompileResult
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_item_bodies<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> CompileResult {
|
pub fn check_item_bodies<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> CompileResult {
|
||||||
ty::queries::typeck_item_bodies::get(tcx, DUMMY_SP, LOCAL_CRATE)
|
tcx.typeck_item_bodies(LOCAL_CRATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn typeck_item_bodies<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) -> CompileResult {
|
fn typeck_item_bodies<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) -> CompileResult {
|
||||||
debug_assert!(crate_num == LOCAL_CRATE);
|
debug_assert!(crate_num == LOCAL_CRATE);
|
||||||
tcx.sess.track_errors(|| {
|
tcx.sess.track_errors(|| {
|
||||||
tcx.visit_all_bodies_in_krate(|body_owner_def_id, _body_id| {
|
tcx.visit_all_bodies_in_krate(|body_owner_def_id, _body_id| {
|
||||||
tcx.item_tables(body_owner_def_id);
|
tcx.typeck_tables_of(body_owner_def_id);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -636,7 +636,7 @@ fn typeck_item_bodies<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub fn provide(providers: &mut Providers) {
|
||||||
*providers = Providers {
|
*providers = Providers {
|
||||||
typeck_item_bodies,
|
typeck_item_bodies,
|
||||||
typeck_tables,
|
typeck_tables_of,
|
||||||
closure_type,
|
closure_type,
|
||||||
closure_kind,
|
closure_kind,
|
||||||
adt_destructor,
|
adt_destructor,
|
||||||
|
@ -648,14 +648,14 @@ fn closure_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
def_id: DefId)
|
def_id: DefId)
|
||||||
-> ty::PolyFnSig<'tcx> {
|
-> ty::PolyFnSig<'tcx> {
|
||||||
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||||
tcx.item_tables(def_id).closure_tys[&node_id]
|
tcx.typeck_tables_of(def_id).closure_tys[&node_id]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn closure_kind<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn closure_kind<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
def_id: DefId)
|
def_id: DefId)
|
||||||
-> ty::ClosureKind {
|
-> ty::ClosureKind {
|
||||||
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||||
tcx.item_tables(def_id).closure_kinds[&node_id]
|
tcx.typeck_tables_of(def_id).closure_kinds[&node_id]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn adt_destructor<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn adt_destructor<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
@ -664,14 +664,14 @@ fn adt_destructor<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
tcx.calculate_dtor(def_id, &mut dropck::check_drop_impl)
|
tcx.calculate_dtor(def_id, &mut dropck::check_drop_impl)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn typeck_tables<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn typeck_tables_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
def_id: DefId)
|
def_id: DefId)
|
||||||
-> &'tcx ty::TypeckTables<'tcx> {
|
-> &'tcx ty::TypeckTables<'tcx> {
|
||||||
// Closures' tables come from their outermost function,
|
// Closures' tables come from their outermost function,
|
||||||
// as they are part of the same "inference environment".
|
// as they are part of the same "inference environment".
|
||||||
let outer_def_id = tcx.closure_base_def_id(def_id);
|
let outer_def_id = tcx.closure_base_def_id(def_id);
|
||||||
if outer_def_id != def_id {
|
if outer_def_id != def_id {
|
||||||
return tcx.item_tables(outer_def_id);
|
return tcx.typeck_tables_of(outer_def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
let id = tcx.hir.as_local_node_id(def_id).unwrap();
|
let id = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||||
|
@ -736,7 +736,7 @@ fn typeck_tables<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
Inherited::build(tcx, id).enter(|inh| {
|
Inherited::build(tcx, id).enter(|inh| {
|
||||||
let fcx = if let Some(decl) = fn_decl {
|
let fcx = if let Some(decl) = fn_decl {
|
||||||
let fn_sig = tcx.item_type(def_id).fn_sig();
|
let fn_sig = tcx.type_of(def_id).fn_sig();
|
||||||
|
|
||||||
check_abi(tcx, span, fn_sig.abi());
|
check_abi(tcx, span, fn_sig.abi());
|
||||||
|
|
||||||
|
@ -752,7 +752,7 @@ fn typeck_tables<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
check_fn(&inh, fn_sig, decl, id, body)
|
check_fn(&inh, fn_sig, decl, id, body)
|
||||||
} else {
|
} else {
|
||||||
let fcx = FnCtxt::new(&inh, body.value.id);
|
let fcx = FnCtxt::new(&inh, body.value.id);
|
||||||
let expected_type = tcx.item_type(def_id);
|
let expected_type = tcx.type_of(def_id);
|
||||||
let expected_type = fcx.normalize_associated_types_in(body.value.span, &expected_type);
|
let expected_type = fcx.normalize_associated_types_in(body.value.span, &expected_type);
|
||||||
fcx.require_type_is_sized(expected_type, body.value.span, traits::ConstSized);
|
fcx.require_type_is_sized(expected_type, body.value.span, traits::ConstSized);
|
||||||
|
|
||||||
|
@ -946,7 +946,7 @@ fn check_struct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
id: ast::NodeId,
|
id: ast::NodeId,
|
||||||
span: Span) {
|
span: Span) {
|
||||||
let def_id = tcx.hir.local_def_id(id);
|
let def_id = tcx.hir.local_def_id(id);
|
||||||
let def = tcx.lookup_adt_def(def_id);
|
let def = tcx.adt_def(def_id);
|
||||||
def.destructor(tcx); // force the destructor to be evaluated
|
def.destructor(tcx); // force the destructor to be evaluated
|
||||||
check_representable(tcx, span, def_id);
|
check_representable(tcx, span, def_id);
|
||||||
|
|
||||||
|
@ -956,7 +956,7 @@ fn check_struct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
// if struct is packed and not aligned, check fields for alignment.
|
// if struct is packed and not aligned, check fields for alignment.
|
||||||
// Checks for combining packed and align attrs on single struct are done elsewhere.
|
// Checks for combining packed and align attrs on single struct are done elsewhere.
|
||||||
if tcx.lookup_adt_def(def_id).repr.packed() && tcx.lookup_adt_def(def_id).repr.align == 0 {
|
if tcx.adt_def(def_id).repr.packed() && tcx.adt_def(def_id).repr.align == 0 {
|
||||||
check_packed(tcx, span, def_id);
|
check_packed(tcx, span, def_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -965,7 +965,7 @@ fn check_union<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
id: ast::NodeId,
|
id: ast::NodeId,
|
||||||
span: Span) {
|
span: Span) {
|
||||||
let def_id = tcx.hir.local_def_id(id);
|
let def_id = tcx.hir.local_def_id(id);
|
||||||
let def = tcx.lookup_adt_def(def_id);
|
let def = tcx.adt_def(def_id);
|
||||||
def.destructor(tcx); // force the destructor to be evaluated
|
def.destructor(tcx); // force the destructor to be evaluated
|
||||||
check_representable(tcx, span, def_id);
|
check_representable(tcx, span, def_id);
|
||||||
}
|
}
|
||||||
|
@ -979,7 +979,7 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item
|
||||||
// Consts can play a role in type-checking, so they are included here.
|
// Consts can play a role in type-checking, so they are included here.
|
||||||
hir::ItemStatic(..) |
|
hir::ItemStatic(..) |
|
||||||
hir::ItemConst(..) => {
|
hir::ItemConst(..) => {
|
||||||
tcx.item_tables(tcx.hir.local_def_id(it.id));
|
tcx.typeck_tables_of(tcx.hir.local_def_id(it.id));
|
||||||
}
|
}
|
||||||
hir::ItemEnum(ref enum_definition, _) => {
|
hir::ItemEnum(ref enum_definition, _) => {
|
||||||
check_enum(tcx,
|
check_enum(tcx,
|
||||||
|
@ -1013,7 +1013,7 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item
|
||||||
}
|
}
|
||||||
hir::ItemTy(_, ref generics) => {
|
hir::ItemTy(_, ref generics) => {
|
||||||
let def_id = tcx.hir.local_def_id(it.id);
|
let def_id = tcx.hir.local_def_id(it.id);
|
||||||
let pty_ty = tcx.item_type(def_id);
|
let pty_ty = tcx.type_of(def_id);
|
||||||
check_bounds_are_used(tcx, generics, pty_ty);
|
check_bounds_are_used(tcx, generics, pty_ty);
|
||||||
}
|
}
|
||||||
hir::ItemForeignMod(ref m) => {
|
hir::ItemForeignMod(ref m) => {
|
||||||
|
@ -1029,7 +1029,7 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for item in &m.items {
|
for item in &m.items {
|
||||||
let generics = tcx.item_generics(tcx.hir.local_def_id(item.id));
|
let generics = tcx.generics_of(tcx.hir.local_def_id(item.id));
|
||||||
if !generics.types.is_empty() {
|
if !generics.types.is_empty() {
|
||||||
let mut err = struct_span_err!(tcx.sess, item.span, E0044,
|
let mut err = struct_span_err!(tcx.sess, item.span, E0044,
|
||||||
"foreign items may not have type parameters");
|
"foreign items may not have type parameters");
|
||||||
|
@ -1052,7 +1052,7 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item
|
||||||
fn check_on_unimplemented<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn check_on_unimplemented<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
item: &hir::Item) {
|
item: &hir::Item) {
|
||||||
let generics = tcx.item_generics(def_id);
|
let generics = tcx.generics_of(def_id);
|
||||||
if let Some(ref attr) = item.attrs.iter().find(|a| {
|
if let Some(ref attr) = item.attrs.iter().find(|a| {
|
||||||
a.check_name("rustc_on_unimplemented")
|
a.check_name("rustc_on_unimplemented")
|
||||||
}) {
|
}) {
|
||||||
|
@ -1159,7 +1159,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
if impl_trait_ref.references_error() { return; }
|
if impl_trait_ref.references_error() { return; }
|
||||||
|
|
||||||
// Locate trait definition and items
|
// Locate trait definition and items
|
||||||
let trait_def = tcx.lookup_trait_def(impl_trait_ref.def_id);
|
let trait_def = tcx.trait_def(impl_trait_ref.def_id);
|
||||||
let mut overridden_associated_type = None;
|
let mut overridden_associated_type = None;
|
||||||
|
|
||||||
let impl_items = || impl_item_refs.iter().map(|iiref| tcx.hir.impl_item(iiref.id));
|
let impl_items = || impl_item_refs.iter().map(|iiref| tcx.hir.impl_item(iiref.id));
|
||||||
|
@ -1280,11 +1280,11 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
let signature = |item: &ty::AssociatedItem| {
|
let signature = |item: &ty::AssociatedItem| {
|
||||||
match item.kind {
|
match item.kind {
|
||||||
ty::AssociatedKind::Method => {
|
ty::AssociatedKind::Method => {
|
||||||
format!("{}", tcx.item_type(item.def_id).fn_sig().0)
|
format!("{}", tcx.type_of(item.def_id).fn_sig().0)
|
||||||
}
|
}
|
||||||
ty::AssociatedKind::Type => format!("type {};", item.name.to_string()),
|
ty::AssociatedKind::Type => format!("type {};", item.name.to_string()),
|
||||||
ty::AssociatedKind::Const => {
|
ty::AssociatedKind::Const => {
|
||||||
format!("const {}: {:?};", item.name.to_string(), tcx.item_type(item.def_id))
|
format!("const {}: {:?};", item.name.to_string(), tcx.type_of(item.def_id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1330,7 +1330,7 @@ fn check_representable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
sp: Span,
|
sp: Span,
|
||||||
item_def_id: DefId)
|
item_def_id: DefId)
|
||||||
-> bool {
|
-> bool {
|
||||||
let rty = tcx.item_type(item_def_id);
|
let rty = tcx.type_of(item_def_id);
|
||||||
|
|
||||||
// Check that it is possible to represent this type. This call identifies
|
// Check that it is possible to represent this type. This call identifies
|
||||||
// (1) types that contain themselves and (2) types that contain a different
|
// (1) types that contain themselves and (2) types that contain a different
|
||||||
|
@ -1348,7 +1348,7 @@ fn check_representable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_simd<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, def_id: DefId) {
|
pub fn check_simd<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, def_id: DefId) {
|
||||||
let t = tcx.item_type(def_id);
|
let t = tcx.type_of(def_id);
|
||||||
match t.sty {
|
match t.sty {
|
||||||
ty::TyAdt(def, substs) if def.is_struct() => {
|
ty::TyAdt(def, substs) if def.is_struct() => {
|
||||||
let fields = &def.struct_variant().fields;
|
let fields = &def.struct_variant().fields;
|
||||||
|
@ -1387,14 +1387,14 @@ fn check_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, def_id: DefId)
|
||||||
fn check_packed_inner<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn check_packed_inner<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
stack: &mut Vec<DefId>) -> bool {
|
stack: &mut Vec<DefId>) -> bool {
|
||||||
let t = tcx.item_type(def_id);
|
let t = tcx.type_of(def_id);
|
||||||
if stack.contains(&def_id) {
|
if stack.contains(&def_id) {
|
||||||
debug!("check_packed_inner: {:?} is recursive", t);
|
debug!("check_packed_inner: {:?} is recursive", t);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
match t.sty {
|
match t.sty {
|
||||||
ty::TyAdt(def, substs) if def.is_struct() => {
|
ty::TyAdt(def, substs) if def.is_struct() => {
|
||||||
if tcx.lookup_adt_def(def.did).repr.align > 0 {
|
if tcx.adt_def(def.did).repr.align > 0 {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// push struct def_id before checking fields
|
// push struct def_id before checking fields
|
||||||
|
@ -1424,7 +1424,7 @@ pub fn check_enum<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
vs: &'tcx [hir::Variant],
|
vs: &'tcx [hir::Variant],
|
||||||
id: ast::NodeId) {
|
id: ast::NodeId) {
|
||||||
let def_id = tcx.hir.local_def_id(id);
|
let def_id = tcx.hir.local_def_id(id);
|
||||||
let def = tcx.lookup_adt_def(def_id);
|
let def = tcx.adt_def(def_id);
|
||||||
def.destructor(tcx); // force the destructor to be evaluated
|
def.destructor(tcx); // force the destructor to be evaluated
|
||||||
|
|
||||||
if vs.is_empty() && tcx.has_attr(def_id, "repr") {
|
if vs.is_empty() && tcx.has_attr(def_id, "repr") {
|
||||||
|
@ -1445,7 +1445,7 @@ pub fn check_enum<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
for v in vs {
|
for v in vs {
|
||||||
if let Some(e) = v.node.disr_expr {
|
if let Some(e) = v.node.disr_expr {
|
||||||
tcx.item_tables(tcx.hir.local_def_id(e.node_id));
|
tcx.typeck_tables_of(tcx.hir.local_def_id(e.node_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1493,7 +1493,7 @@ impl<'a, 'gcx, 'tcx> AstConv<'gcx, 'tcx> for FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||||
let item_id = tcx.hir.ty_param_owner(node_id);
|
let item_id = tcx.hir.ty_param_owner(node_id);
|
||||||
let item_def_id = tcx.hir.local_def_id(item_id);
|
let item_def_id = tcx.hir.local_def_id(item_id);
|
||||||
let generics = tcx.item_generics(item_def_id);
|
let generics = tcx.generics_of(item_def_id);
|
||||||
let index = generics.type_param_to_index[&def_id.index];
|
let index = generics.type_param_to_index[&def_id.index];
|
||||||
ty::GenericPredicates {
|
ty::GenericPredicates {
|
||||||
parent: None,
|
parent: None,
|
||||||
|
@ -1792,7 +1792,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
/// generic type scheme.
|
/// generic type scheme.
|
||||||
fn instantiate_bounds(&self, span: Span, def_id: DefId, substs: &Substs<'tcx>)
|
fn instantiate_bounds(&self, span: Span, def_id: DefId, substs: &Substs<'tcx>)
|
||||||
-> ty::InstantiatedPredicates<'tcx> {
|
-> ty::InstantiatedPredicates<'tcx> {
|
||||||
let bounds = self.tcx.item_predicates(def_id);
|
let bounds = self.tcx.predicates_of(def_id);
|
||||||
let result = bounds.instantiate(self.tcx, substs);
|
let result = bounds.instantiate(self.tcx, substs);
|
||||||
let result = self.normalize_associated_types_in(span, &result);
|
let result = self.normalize_associated_types_in(span, &result);
|
||||||
debug!("instantiate_bounds(bounds={:?}, substs={:?}) = {:?}",
|
debug!("instantiate_bounds(bounds={:?}, substs={:?}) = {:?}",
|
||||||
|
@ -1817,8 +1817,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
let ty_var = self.next_ty_var(TypeVariableOrigin::TypeInference(span));
|
let ty_var = self.next_ty_var(TypeVariableOrigin::TypeInference(span));
|
||||||
self.anon_types.borrow_mut().insert(id, ty_var);
|
self.anon_types.borrow_mut().insert(id, ty_var);
|
||||||
|
|
||||||
let item_predicates = self.tcx.item_predicates(def_id);
|
let predicates_of = self.tcx.predicates_of(def_id);
|
||||||
let bounds = item_predicates.instantiate(self.tcx, substs);
|
let bounds = predicates_of.instantiate(self.tcx, substs);
|
||||||
|
|
||||||
for predicate in bounds.predicates {
|
for predicate in bounds.predicates {
|
||||||
// Change the predicate to refer to the type variable,
|
// Change the predicate to refer to the type variable,
|
||||||
|
@ -2614,7 +2614,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
span: Span, // (potential) receiver for this impl
|
span: Span, // (potential) receiver for this impl
|
||||||
did: DefId)
|
did: DefId)
|
||||||
-> TypeAndSubsts<'tcx> {
|
-> TypeAndSubsts<'tcx> {
|
||||||
let ity = self.tcx.item_type(did);
|
let ity = self.tcx.type_of(did);
|
||||||
debug!("impl_self_ty: ity={:?}", ity);
|
debug!("impl_self_ty: ity={:?}", ity);
|
||||||
|
|
||||||
let substs = self.fresh_substs_for_item(span, did);
|
let substs = self.fresh_substs_for_item(span, did);
|
||||||
|
@ -4208,11 +4208,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
Def::VariantCtor(def_id, ..) => {
|
Def::VariantCtor(def_id, ..) => {
|
||||||
// Everything but the final segment should have no
|
// Everything but the final segment should have no
|
||||||
// parameters at all.
|
// parameters at all.
|
||||||
let mut generics = self.tcx.item_generics(def_id);
|
let mut generics = self.tcx.generics_of(def_id);
|
||||||
if let Some(def_id) = generics.parent {
|
if let Some(def_id) = generics.parent {
|
||||||
// Variant and struct constructors use the
|
// Variant and struct constructors use the
|
||||||
// generics of their parent type definition.
|
// generics of their parent type definition.
|
||||||
generics = self.tcx.item_generics(def_id);
|
generics = self.tcx.generics_of(def_id);
|
||||||
}
|
}
|
||||||
type_segment = Some((segments.last().unwrap(), generics));
|
type_segment = Some((segments.last().unwrap(), generics));
|
||||||
}
|
}
|
||||||
|
@ -4222,7 +4222,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
Def::Const(def_id) |
|
Def::Const(def_id) |
|
||||||
Def::Static(def_id, _) => {
|
Def::Static(def_id, _) => {
|
||||||
fn_segment = Some((segments.last().unwrap(),
|
fn_segment = Some((segments.last().unwrap(),
|
||||||
self.tcx.item_generics(def_id)));
|
self.tcx.generics_of(def_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Case 3. Reference to a method or associated const.
|
// Case 3. Reference to a method or associated const.
|
||||||
|
@ -4236,9 +4236,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
ty::ImplContainer(_) => {}
|
ty::ImplContainer(_) => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let generics = self.tcx.item_generics(def_id);
|
let generics = self.tcx.generics_of(def_id);
|
||||||
if segments.len() >= 2 {
|
if segments.len() >= 2 {
|
||||||
let parent_generics = self.tcx.item_generics(generics.parent.unwrap());
|
let parent_generics = self.tcx.generics_of(generics.parent.unwrap());
|
||||||
type_segment = Some((&segments[segments.len() - 2], parent_generics));
|
type_segment = Some((&segments[segments.len() - 2], parent_generics));
|
||||||
} else {
|
} else {
|
||||||
// `<T>::assoc` will end up here, and so can `T::assoc`.
|
// `<T>::assoc` will end up here, and so can `T::assoc`.
|
||||||
|
@ -4351,7 +4351,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
self.to_ty(ast_ty)
|
self.to_ty(ast_ty)
|
||||||
} else if !infer_types && def.has_default {
|
} else if !infer_types && def.has_default {
|
||||||
// No type parameter provided, but a default exists.
|
// No type parameter provided, but a default exists.
|
||||||
let default = self.tcx.item_type(def.def_id);
|
let default = self.tcx.type_of(def.def_id);
|
||||||
self.normalize_ty(
|
self.normalize_ty(
|
||||||
span,
|
span,
|
||||||
default.subst_spanned(self.tcx, substs, Some(span))
|
default.subst_spanned(self.tcx, substs, Some(span))
|
||||||
|
@ -4367,7 +4367,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
// The things we are substituting into the type should not contain
|
// The things we are substituting into the type should not contain
|
||||||
// escaping late-bound regions, and nor should the base type scheme.
|
// escaping late-bound regions, and nor should the base type scheme.
|
||||||
let ty = self.tcx.item_type(def.def_id());
|
let ty = self.tcx.type_of(def.def_id());
|
||||||
assert!(!substs.has_escaping_regions());
|
assert!(!substs.has_escaping_regions());
|
||||||
assert!(!ty.has_escaping_regions());
|
assert!(!ty.has_escaping_regions());
|
||||||
|
|
||||||
|
@ -4387,7 +4387,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
// is inherent, there is no `Self` parameter, instead, the impl needs
|
// is inherent, there is no `Self` parameter, instead, the impl needs
|
||||||
// type parameters, which we can infer by unifying the provided `Self`
|
// type parameters, which we can infer by unifying the provided `Self`
|
||||||
// with the substituted impl type.
|
// with the substituted impl type.
|
||||||
let ty = self.tcx.item_type(impl_def_id);
|
let ty = self.tcx.type_of(impl_def_id);
|
||||||
|
|
||||||
let impl_ty = self.instantiate_type_scheme(span, &substs, &ty);
|
let impl_ty = self.instantiate_type_scheme(span, &substs, &ty);
|
||||||
match self.sub_types(false, &self.misc(span), self_ty, impl_ty) {
|
match self.sub_types(false, &self.misc(span), self_ty, impl_ty) {
|
||||||
|
|
|
@ -1725,7 +1725,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
|
||||||
// ```
|
// ```
|
||||||
//
|
//
|
||||||
// we can thus deduce that `<T as SomeTrait<'a>>::SomeType : 'a`.
|
// we can thus deduce that `<T as SomeTrait<'a>>::SomeType : 'a`.
|
||||||
let trait_predicates = self.tcx.item_predicates(projection_ty.trait_ref.def_id);
|
let trait_predicates = self.tcx.predicates_of(projection_ty.trait_ref.def_id);
|
||||||
assert_eq!(trait_predicates.parent, None);
|
assert_eq!(trait_predicates.parent, None);
|
||||||
let predicates = trait_predicates.predicates.as_slice().to_vec();
|
let predicates = trait_predicates.predicates.as_slice().to_vec();
|
||||||
traits::elaborate_predicates(self.tcx, predicates)
|
traits::elaborate_predicates(self.tcx, predicates)
|
||||||
|
|
|
@ -168,18 +168,18 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
|
||||||
let (mut implied_bounds, self_ty) = match item.container {
|
let (mut implied_bounds, self_ty) = match item.container {
|
||||||
ty::TraitContainer(_) => (vec![], fcx.tcx.mk_self_type()),
|
ty::TraitContainer(_) => (vec![], fcx.tcx.mk_self_type()),
|
||||||
ty::ImplContainer(def_id) => (fcx.impl_implied_bounds(def_id, span),
|
ty::ImplContainer(def_id) => (fcx.impl_implied_bounds(def_id, span),
|
||||||
fcx.tcx.item_type(def_id))
|
fcx.tcx.type_of(def_id))
|
||||||
};
|
};
|
||||||
|
|
||||||
match item.kind {
|
match item.kind {
|
||||||
ty::AssociatedKind::Const => {
|
ty::AssociatedKind::Const => {
|
||||||
let ty = fcx.tcx.item_type(item.def_id);
|
let ty = fcx.tcx.type_of(item.def_id);
|
||||||
let ty = fcx.instantiate_type_scheme(span, free_substs, &ty);
|
let ty = fcx.instantiate_type_scheme(span, free_substs, &ty);
|
||||||
fcx.register_wf_obligation(ty, span, code.clone());
|
fcx.register_wf_obligation(ty, span, code.clone());
|
||||||
}
|
}
|
||||||
ty::AssociatedKind::Method => {
|
ty::AssociatedKind::Method => {
|
||||||
reject_shadowing_type_parameters(fcx.tcx, item.def_id);
|
reject_shadowing_type_parameters(fcx.tcx, item.def_id);
|
||||||
let method_ty = fcx.tcx.item_type(item.def_id);
|
let method_ty = fcx.tcx.type_of(item.def_id);
|
||||||
let method_ty = fcx.instantiate_type_scheme(span, free_substs, &method_ty);
|
let method_ty = fcx.instantiate_type_scheme(span, free_substs, &method_ty);
|
||||||
let predicates = fcx.instantiate_bounds(span, item.def_id, free_substs);
|
let predicates = fcx.instantiate_bounds(span, item.def_id, free_substs);
|
||||||
let sig = method_ty.fn_sig();
|
let sig = method_ty.fn_sig();
|
||||||
|
@ -191,7 +191,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
|
||||||
}
|
}
|
||||||
ty::AssociatedKind::Type => {
|
ty::AssociatedKind::Type => {
|
||||||
if item.defaultness.has_value() {
|
if item.defaultness.has_value() {
|
||||||
let ty = fcx.tcx.item_type(item.def_id);
|
let ty = fcx.tcx.type_of(item.def_id);
|
||||||
let ty = fcx.instantiate_type_scheme(span, free_substs, &ty);
|
let ty = fcx.instantiate_type_scheme(span, free_substs, &ty);
|
||||||
fcx.register_wf_obligation(ty, span, code.clone());
|
fcx.register_wf_obligation(ty, span, code.clone());
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
|
||||||
//
|
//
|
||||||
// 3) that the trait definition does not have any type parameters
|
// 3) that the trait definition does not have any type parameters
|
||||||
|
|
||||||
let predicates = self.tcx.item_predicates(trait_def_id);
|
let predicates = self.tcx.predicates_of(trait_def_id);
|
||||||
|
|
||||||
// We must exclude the Self : Trait predicate contained by all
|
// We must exclude the Self : Trait predicate contained by all
|
||||||
// traits.
|
// traits.
|
||||||
|
@ -277,7 +277,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let has_ty_params = self.tcx.item_generics(trait_def_id).types.len() > 1;
|
let has_ty_params = self.tcx.generics_of(trait_def_id).types.len() > 1;
|
||||||
|
|
||||||
// We use an if-else here, since the generics will also trigger
|
// We use an if-else here, since the generics will also trigger
|
||||||
// an extraneous error message when we find predicates like
|
// an extraneous error message when we find predicates like
|
||||||
|
@ -334,7 +334,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
|
||||||
self.for_item(item).with_fcx(|fcx, this| {
|
self.for_item(item).with_fcx(|fcx, this| {
|
||||||
let free_substs = &fcx.parameter_environment.free_substs;
|
let free_substs = &fcx.parameter_environment.free_substs;
|
||||||
let def_id = fcx.tcx.hir.local_def_id(item.id);
|
let def_id = fcx.tcx.hir.local_def_id(item.id);
|
||||||
let ty = fcx.tcx.item_type(def_id);
|
let ty = fcx.tcx.type_of(def_id);
|
||||||
let item_ty = fcx.instantiate_type_scheme(item.span, free_substs, &ty);
|
let item_ty = fcx.instantiate_type_scheme(item.span, free_substs, &ty);
|
||||||
let sig = item_ty.fn_sig();
|
let sig = item_ty.fn_sig();
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
|
||||||
debug!("check_item_type: {:?}", item);
|
debug!("check_item_type: {:?}", item);
|
||||||
|
|
||||||
self.for_item(item).with_fcx(|fcx, this| {
|
self.for_item(item).with_fcx(|fcx, this| {
|
||||||
let ty = fcx.tcx.item_type(fcx.tcx.hir.local_def_id(item.id));
|
let ty = fcx.tcx.type_of(fcx.tcx.hir.local_def_id(item.id));
|
||||||
let item_ty = fcx.instantiate_type_scheme(item.span,
|
let item_ty = fcx.instantiate_type_scheme(item.span,
|
||||||
&fcx.parameter_environment
|
&fcx.parameter_environment
|
||||||
.free_substs,
|
.free_substs,
|
||||||
|
@ -393,7 +393,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let self_ty = fcx.tcx.item_type(item_def_id);
|
let self_ty = fcx.tcx.type_of(item_def_id);
|
||||||
let self_ty = fcx.instantiate_type_scheme(item.span, free_substs, &self_ty);
|
let self_ty = fcx.instantiate_type_scheme(item.span, free_substs, &self_ty);
|
||||||
fcx.register_wf_obligation(self_ty, ast_self_ty.span, this.code.clone());
|
fcx.register_wf_obligation(self_ty, ast_self_ty.span, this.code.clone());
|
||||||
}
|
}
|
||||||
|
@ -468,7 +468,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
|
||||||
let span = method_sig.decl.inputs[0].span;
|
let span = method_sig.decl.inputs[0].span;
|
||||||
|
|
||||||
let free_substs = &fcx.parameter_environment.free_substs;
|
let free_substs = &fcx.parameter_environment.free_substs;
|
||||||
let method_ty = fcx.tcx.item_type(method.def_id);
|
let method_ty = fcx.tcx.type_of(method.def_id);
|
||||||
let fty = fcx.instantiate_type_scheme(span, free_substs, &method_ty);
|
let fty = fcx.instantiate_type_scheme(span, free_substs, &method_ty);
|
||||||
let sig = fcx.tcx.liberate_late_bound_regions(free_id_outlive, &fty.fn_sig());
|
let sig = fcx.tcx.liberate_late_bound_regions(free_id_outlive, &fty.fn_sig());
|
||||||
|
|
||||||
|
@ -502,14 +502,14 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
|
||||||
ast_generics: &hir::Generics)
|
ast_generics: &hir::Generics)
|
||||||
{
|
{
|
||||||
let item_def_id = self.tcx.hir.local_def_id(item.id);
|
let item_def_id = self.tcx.hir.local_def_id(item.id);
|
||||||
let ty = self.tcx.item_type(item_def_id);
|
let ty = self.tcx.type_of(item_def_id);
|
||||||
if self.tcx.has_error_field(ty) {
|
if self.tcx.has_error_field(ty) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let ty_predicates = self.tcx.item_predicates(item_def_id);
|
let ty_predicates = self.tcx.predicates_of(item_def_id);
|
||||||
assert_eq!(ty_predicates.parent, None);
|
assert_eq!(ty_predicates.parent, None);
|
||||||
let variances = self.tcx.item_variances(item_def_id);
|
let variances = self.tcx.variances_of(item_def_id);
|
||||||
|
|
||||||
let mut constrained_parameters: FxHashSet<_> =
|
let mut constrained_parameters: FxHashSet<_> =
|
||||||
variances.iter().enumerate()
|
variances.iter().enumerate()
|
||||||
|
@ -561,8 +561,8 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reject_shadowing_type_parameters(tcx: TyCtxt, def_id: DefId) {
|
fn reject_shadowing_type_parameters(tcx: TyCtxt, def_id: DefId) {
|
||||||
let generics = tcx.item_generics(def_id);
|
let generics = tcx.generics_of(def_id);
|
||||||
let parent = tcx.item_generics(generics.parent.unwrap());
|
let parent = tcx.generics_of(generics.parent.unwrap());
|
||||||
let impl_params: FxHashMap<_, _> = parent.types
|
let impl_params: FxHashMap<_, _> = parent.types
|
||||||
.iter()
|
.iter()
|
||||||
.map(|tp| (tp.name, tp.def_id))
|
.map(|tp| (tp.name, tp.def_id))
|
||||||
|
@ -631,7 +631,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
let fields =
|
let fields =
|
||||||
struct_def.fields().iter()
|
struct_def.fields().iter()
|
||||||
.map(|field| {
|
.map(|field| {
|
||||||
let field_ty = self.tcx.item_type(self.tcx.hir.local_def_id(field.id));
|
let field_ty = self.tcx.type_of(self.tcx.hir.local_def_id(field.id));
|
||||||
let field_ty = self.instantiate_type_scheme(field.span,
|
let field_ty = self.instantiate_type_scheme(field.span,
|
||||||
&self.parameter_environment
|
&self.parameter_environment
|
||||||
.free_substs,
|
.free_substs,
|
||||||
|
@ -660,7 +660,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
None => {
|
None => {
|
||||||
// Inherent impl: take implied bounds from the self type.
|
// Inherent impl: take implied bounds from the self type.
|
||||||
let self_ty = self.tcx.item_type(impl_def_id);
|
let self_ty = self.tcx.type_of(impl_def_id);
|
||||||
let self_ty = self.instantiate_type_scheme(span, free_substs, &self_ty);
|
let self_ty = self.instantiate_type_scheme(span, free_substs, &self_ty);
|
||||||
vec![self_ty]
|
vec![self_ty]
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||||
let item_def_id = tcx.hir.local_def_id(item_id);
|
let item_def_id = tcx.hir.local_def_id(item_id);
|
||||||
|
|
||||||
// this will have been written by the main typeck pass
|
// this will have been written by the main typeck pass
|
||||||
if let Some(tables) = tcx.maps.typeck_tables.borrow().get(&item_def_id) {
|
if let Some(tables) = tcx.maps.typeck_tables_of.borrow().get(&item_def_id) {
|
||||||
let imports = &tables.used_trait_imports;
|
let imports = &tables.used_trait_imports;
|
||||||
debug!("GatherVisitor: item_def_id={:?} with imports {:#?}", item_def_id, imports);
|
debug!("GatherVisitor: item_def_id={:?} with imports {:#?}", item_def_id, imports);
|
||||||
used_trait_imports.extend(imports);
|
used_trait_imports.extend(imports);
|
||||||
|
|
|
@ -57,7 +57,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
|
||||||
fn visit_implementation_of_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn visit_implementation_of_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
_drop_did: DefId,
|
_drop_did: DefId,
|
||||||
impl_did: DefId) {
|
impl_did: DefId) {
|
||||||
match tcx.item_type(impl_did).sty {
|
match tcx.type_of(impl_did).sty {
|
||||||
ty::TyAdt(..) => {}
|
ty::TyAdt(..) => {}
|
||||||
_ => {
|
_ => {
|
||||||
// Destructors only work on nominal types.
|
// Destructors only work on nominal types.
|
||||||
|
@ -101,7 +101,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let self_type = tcx.item_type(impl_did);
|
let self_type = tcx.type_of(impl_did);
|
||||||
debug!("visit_implementation_of_copy: self_type={:?} (bound)",
|
debug!("visit_implementation_of_copy: self_type={:?} (bound)",
|
||||||
self_type);
|
self_type);
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
// course.
|
// course.
|
||||||
if impl_did.is_local() {
|
if impl_did.is_local() {
|
||||||
let span = tcx.def_span(impl_did);
|
let span = tcx.def_span(impl_did);
|
||||||
ty::queries::coerce_unsized_info::get(tcx, span, impl_did);
|
tcx.at(span).coerce_unsized_info(impl_did);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
bug!("coerce_unsized_info: invoked for non-local def-id {:?}", impl_did)
|
bug!("coerce_unsized_info: invoked for non-local def-id {:?}", impl_did)
|
||||||
});
|
});
|
||||||
|
|
||||||
let source = tcx.item_type(impl_did);
|
let source = tcx.type_of(impl_did);
|
||||||
let trait_ref = tcx.impl_trait_ref(impl_did).unwrap();
|
let trait_ref = tcx.impl_trait_ref(impl_did).unwrap();
|
||||||
assert_eq!(trait_ref.def_id, coerce_unsized_trait);
|
assert_eq!(trait_ref.def_id, coerce_unsized_trait);
|
||||||
let target = trait_ref.substs.type_at(1);
|
let target = trait_ref.substs.type_at(1);
|
||||||
|
@ -259,7 +259,7 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
.filter_map(|(i, f)| {
|
.filter_map(|(i, f)| {
|
||||||
let (a, b) = (f.ty(tcx, substs_a), f.ty(tcx, substs_b));
|
let (a, b) = (f.ty(tcx, substs_a), f.ty(tcx, substs_b));
|
||||||
|
|
||||||
if tcx.item_type(f.did).is_phantom_data() {
|
if tcx.type_of(f.did).is_phantom_data() {
|
||||||
// Ignore PhantomData fields
|
// Ignore PhantomData fields
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
//! for any change, but it is very cheap to compute. In practice, most
|
//! for any change, but it is very cheap to compute. In practice, most
|
||||||
//! code in the compiler never *directly* requests this map. Instead,
|
//! code in the compiler never *directly* requests this map. Instead,
|
||||||
//! it requests the inherent impls specific to some type (via
|
//! it requests the inherent impls specific to some type (via
|
||||||
//! `ty::queries::inherent_impls::get(def_id)`). That value, however,
|
//! `tcx.inherent_impls(def_id)`). That value, however,
|
||||||
//! is computed by selecting an idea from this table.
|
//! is computed by selecting an idea from this table.
|
||||||
|
|
||||||
use rustc::dep_graph::DepNode;
|
use rustc::dep_graph::DepNode;
|
||||||
|
@ -26,7 +26,7 @@ use rustc::util::nodemap::DefIdMap;
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax_pos::{DUMMY_SP, Span};
|
use syntax_pos::Span;
|
||||||
|
|
||||||
/// On-demand query: yields a map containing all types mapped to their inherent impls.
|
/// On-demand query: yields a map containing all types mapped to their inherent impls.
|
||||||
pub fn crate_inherent_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
pub fn crate_inherent_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
@ -67,7 +67,7 @@ pub fn inherent_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
// [the plan]: https://github.com/rust-lang/rust-roadmap/issues/4
|
// [the plan]: https://github.com/rust-lang/rust-roadmap/issues/4
|
||||||
|
|
||||||
let result = tcx.dep_graph.with_ignore(|| {
|
let result = tcx.dep_graph.with_ignore(|| {
|
||||||
let crate_map = ty::queries::crate_inherent_impls::get(tcx, DUMMY_SP, ty_def_id.krate);
|
let crate_map = tcx.crate_inherent_impls(ty_def_id.krate);
|
||||||
match crate_map.inherent_impls.get(&ty_def_id) {
|
match crate_map.inherent_impls.get(&ty_def_id) {
|
||||||
Some(v) => v.clone(),
|
Some(v) => v.clone(),
|
||||||
None => Rc::new(vec![]),
|
None => Rc::new(vec![]),
|
||||||
|
@ -106,7 +106,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let def_id = self.tcx.hir.local_def_id(item.id);
|
let def_id = self.tcx.hir.local_def_id(item.id);
|
||||||
let self_ty = self.tcx.item_type(def_id);
|
let self_ty = self.tcx.type_of(def_id);
|
||||||
match self_ty.sty {
|
match self_ty.sty {
|
||||||
ty::TyAdt(def, _) => {
|
ty::TyAdt(def, _) => {
|
||||||
self.check_def_id(item, def.did);
|
self.check_def_id(item, def.did);
|
||||||
|
|
|
@ -14,8 +14,6 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
||||||
use rustc::traits::{self, Reveal};
|
use rustc::traits::{self, Reveal};
|
||||||
use rustc::ty::{self, TyCtxt};
|
use rustc::ty::{self, TyCtxt};
|
||||||
|
|
||||||
use syntax_pos::DUMMY_SP;
|
|
||||||
|
|
||||||
pub fn crate_inherent_impls_overlap_check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
pub fn crate_inherent_impls_overlap_check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
crate_num: CrateNum) {
|
crate_num: CrateNum) {
|
||||||
assert_eq!(crate_num, LOCAL_CRATE);
|
assert_eq!(crate_num, LOCAL_CRATE);
|
||||||
|
@ -68,7 +66,7 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_for_overlapping_inherent_impls(&self, ty_def_id: DefId) {
|
fn check_for_overlapping_inherent_impls(&self, ty_def_id: DefId) {
|
||||||
let impls = ty::queries::inherent_impls::get(self.tcx, DUMMY_SP, ty_def_id);
|
let impls = self.tcx.inherent_impls(ty_def_id);
|
||||||
|
|
||||||
for (i, &impl1_def_id) in impls.iter().enumerate() {
|
for (i, &impl1_def_id) in impls.iter().enumerate() {
|
||||||
for &impl2_def_id in &impls[(i + 1)..] {
|
for &impl2_def_id in &impls[(i + 1)..] {
|
||||||
|
|
|
@ -16,11 +16,10 @@
|
||||||
// mappings. That mapping code resides here.
|
// mappings. That mapping code resides here.
|
||||||
|
|
||||||
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||||
use rustc::ty::{self, TyCtxt, TypeFoldable};
|
use rustc::ty::{TyCtxt, TypeFoldable};
|
||||||
use rustc::ty::maps::Providers;
|
use rustc::ty::maps::Providers;
|
||||||
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax_pos::DUMMY_SP;
|
|
||||||
|
|
||||||
mod builtin;
|
mod builtin;
|
||||||
mod inherent_impls;
|
mod inherent_impls;
|
||||||
|
@ -47,7 +46,7 @@ fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
enforce_trait_manually_implementable(tcx, impl_def_id, trait_ref.def_id);
|
enforce_trait_manually_implementable(tcx, impl_def_id, trait_ref.def_id);
|
||||||
let trait_def = tcx.lookup_trait_def(trait_ref.def_id);
|
let trait_def = tcx.trait_def(trait_ref.def_id);
|
||||||
trait_def.record_local_impl(tcx, impl_def_id, trait_ref);
|
trait_def.record_local_impl(tcx, impl_def_id, trait_ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +131,7 @@ fn coherent_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
pub fn check_coherence<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
pub fn check_coherence<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||||
for &trait_def_id in tcx.hir.krate().trait_impls.keys() {
|
for &trait_def_id in tcx.hir.krate().trait_impls.keys() {
|
||||||
ty::queries::coherent_trait::get(tcx, DUMMY_SP, (LOCAL_CRATE, trait_def_id));
|
tcx.coherent_trait((LOCAL_CRATE, trait_def_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafety::check(tcx);
|
unsafety::check(tcx);
|
||||||
|
@ -140,6 +139,6 @@ pub fn check_coherence<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||||
overlap::check_default_impls(tcx);
|
overlap::check_default_impls(tcx);
|
||||||
|
|
||||||
// these queries are executed for side-effects (error reporting):
|
// these queries are executed for side-effects (error reporting):
|
||||||
ty::queries::crate_inherent_impls::get(tcx, DUMMY_SP, LOCAL_CRATE);
|
tcx.crate_inherent_impls(LOCAL_CRATE);
|
||||||
ty::queries::crate_inherent_impls_overlap_check::get(tcx, DUMMY_SP, LOCAL_CRATE);
|
tcx.crate_inherent_impls_overlap_check(LOCAL_CRATE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ pub fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) {
|
||||||
let _task =
|
let _task =
|
||||||
tcx.dep_graph.in_task(DepNode::CoherenceOverlapCheck(trait_def_id));
|
tcx.dep_graph.in_task(DepNode::CoherenceOverlapCheck(trait_def_id));
|
||||||
|
|
||||||
let def = tcx.lookup_trait_def(trait_def_id);
|
let def = tcx.trait_def(trait_def_id);
|
||||||
|
|
||||||
// attempt to insert into the specialization graph
|
// attempt to insert into the specialization graph
|
||||||
let insert_result = def.add_impl_for_specialization(tcx, impl_def_id);
|
let insert_result = def.add_impl_for_specialization(tcx, impl_def_id);
|
||||||
|
|
|
@ -34,7 +34,7 @@ impl<'cx, 'tcx, 'v> UnsafetyChecker<'cx, 'tcx> {
|
||||||
None => {}
|
None => {}
|
||||||
|
|
||||||
Some(trait_ref) => {
|
Some(trait_ref) => {
|
||||||
let trait_def = self.tcx.lookup_trait_def(trait_ref.def_id);
|
let trait_def = self.tcx.trait_def(trait_ref.def_id);
|
||||||
let unsafe_attr = impl_generics.and_then(|g| g.carries_unsafe_attr());
|
let unsafe_attr = impl_generics.and_then(|g| g.carries_unsafe_attr());
|
||||||
match (trait_def.unsafety, unsafe_attr, unsafety, polarity) {
|
match (trait_def.unsafety, unsafe_attr, unsafety, polarity) {
|
||||||
(_, _, Unsafety::Unsafe, hir::ImplPolarity::Negative) => {
|
(_, _, Unsafety::Unsafe, hir::ImplPolarity::Negative) => {
|
||||||
|
|
|
@ -31,7 +31,7 @@ then types, or something like that) because the user can introduce
|
||||||
arbitrary interdependencies. So instead we generally convert things
|
arbitrary interdependencies. So instead we generally convert things
|
||||||
lazilly and on demand, and include logic that checks for cycles.
|
lazilly and on demand, and include logic that checks for cycles.
|
||||||
Demand is driven by calls to `AstConv::get_item_type_scheme` or
|
Demand is driven by calls to `AstConv::get_item_type_scheme` or
|
||||||
`AstConv::lookup_trait_def`.
|
`AstConv::trait_def`.
|
||||||
|
|
||||||
Currently, we "convert" types and traits in two phases (note that
|
Currently, we "convert" types and traits in two phases (note that
|
||||||
conversion only affects the types of items / enum variants / methods;
|
conversion only affects the types of items / enum variants / methods;
|
||||||
|
@ -91,10 +91,10 @@ pub fn collect_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub fn provide(providers: &mut Providers) {
|
||||||
*providers = Providers {
|
*providers = Providers {
|
||||||
ty,
|
type_of,
|
||||||
generics,
|
generics_of,
|
||||||
predicates,
|
predicates_of,
|
||||||
super_predicates,
|
super_predicates_of,
|
||||||
type_param_predicates,
|
type_param_predicates,
|
||||||
trait_def,
|
trait_def,
|
||||||
adt_def,
|
adt_def,
|
||||||
|
@ -141,7 +141,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> {
|
||||||
for param in &generics.ty_params {
|
for param in &generics.ty_params {
|
||||||
if param.default.is_some() {
|
if param.default.is_some() {
|
||||||
let def_id = self.tcx.hir.local_def_id(param.id);
|
let def_id = self.tcx.hir.local_def_id(param.id);
|
||||||
self.tcx.item_type(def_id);
|
self.tcx.type_of(def_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
intravisit::walk_generics(self, generics);
|
intravisit::walk_generics(self, generics);
|
||||||
|
@ -150,8 +150,8 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> {
|
||||||
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
|
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
|
||||||
if let hir::ExprClosure(..) = expr.node {
|
if let hir::ExprClosure(..) = expr.node {
|
||||||
let def_id = self.tcx.hir.local_def_id(expr.id);
|
let def_id = self.tcx.hir.local_def_id(expr.id);
|
||||||
self.tcx.item_generics(def_id);
|
self.tcx.generics_of(def_id);
|
||||||
self.tcx.item_type(def_id);
|
self.tcx.type_of(def_id);
|
||||||
}
|
}
|
||||||
intravisit::walk_expr(self, expr);
|
intravisit::walk_expr(self, expr);
|
||||||
}
|
}
|
||||||
|
@ -159,8 +159,8 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> {
|
||||||
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
|
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
|
||||||
if let hir::TyImplTrait(..) = ty.node {
|
if let hir::TyImplTrait(..) = ty.node {
|
||||||
let def_id = self.tcx.hir.local_def_id(ty.id);
|
let def_id = self.tcx.hir.local_def_id(ty.id);
|
||||||
self.tcx.item_generics(def_id);
|
self.tcx.generics_of(def_id);
|
||||||
self.tcx.item_predicates(def_id);
|
self.tcx.predicates_of(def_id);
|
||||||
}
|
}
|
||||||
intravisit::walk_ty(self, ty);
|
intravisit::walk_ty(self, ty);
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ impl<'a, 'tcx> AstConv<'tcx, 'tcx> for ItemCtxt<'a, 'tcx> {
|
||||||
def_id: DefId)
|
def_id: DefId)
|
||||||
-> ty::GenericPredicates<'tcx>
|
-> ty::GenericPredicates<'tcx>
|
||||||
{
|
{
|
||||||
ty::queries::type_param_predicates::get(self.tcx, span, (self.item_def_id, def_id))
|
self.tcx.at(span).type_param_predicates((self.item_def_id, def_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_free_substs(&self) -> Option<&Substs<'tcx>> {
|
fn get_free_substs(&self) -> Option<&Substs<'tcx>> {
|
||||||
|
@ -271,7 +271,7 @@ fn type_param_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
let param_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
let param_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||||
let param_owner = tcx.hir.ty_param_owner(param_id);
|
let param_owner = tcx.hir.ty_param_owner(param_id);
|
||||||
let param_owner_def_id = tcx.hir.local_def_id(param_owner);
|
let param_owner_def_id = tcx.hir.local_def_id(param_owner);
|
||||||
let generics = tcx.item_generics(param_owner_def_id);
|
let generics = tcx.generics_of(param_owner_def_id);
|
||||||
let index = generics.type_param_to_index[&def_id.index];
|
let index = generics.type_param_to_index[&def_id.index];
|
||||||
let ty = tcx.mk_param(index, tcx.hir.ty_param_name(param_id));
|
let ty = tcx.mk_param(index, tcx.hir.ty_param_name(param_id));
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ fn type_param_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
let parent = if item_def_id == param_owner_def_id {
|
let parent = if item_def_id == param_owner_def_id {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
tcx.item_generics(item_def_id).parent
|
tcx.generics_of(item_def_id).parent
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut result = parent.map_or(ty::GenericPredicates {
|
let mut result = parent.map_or(ty::GenericPredicates {
|
||||||
|
@ -452,43 +452,43 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
|
||||||
hir::ItemForeignMod(ref foreign_mod) => {
|
hir::ItemForeignMod(ref foreign_mod) => {
|
||||||
for item in &foreign_mod.items {
|
for item in &foreign_mod.items {
|
||||||
let def_id = tcx.hir.local_def_id(item.id);
|
let def_id = tcx.hir.local_def_id(item.id);
|
||||||
tcx.item_generics(def_id);
|
tcx.generics_of(def_id);
|
||||||
tcx.item_type(def_id);
|
tcx.type_of(def_id);
|
||||||
tcx.item_predicates(def_id);
|
tcx.predicates_of(def_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ItemEnum(ref enum_definition, _) => {
|
hir::ItemEnum(ref enum_definition, _) => {
|
||||||
tcx.item_generics(def_id);
|
tcx.generics_of(def_id);
|
||||||
tcx.item_type(def_id);
|
tcx.type_of(def_id);
|
||||||
tcx.item_predicates(def_id);
|
tcx.predicates_of(def_id);
|
||||||
convert_enum_variant_types(tcx, def_id, &enum_definition.variants);
|
convert_enum_variant_types(tcx, def_id, &enum_definition.variants);
|
||||||
},
|
},
|
||||||
hir::ItemDefaultImpl(..) => {
|
hir::ItemDefaultImpl(..) => {
|
||||||
tcx.impl_trait_ref(def_id);
|
tcx.impl_trait_ref(def_id);
|
||||||
}
|
}
|
||||||
hir::ItemImpl(..) => {
|
hir::ItemImpl(..) => {
|
||||||
tcx.item_generics(def_id);
|
tcx.generics_of(def_id);
|
||||||
tcx.item_type(def_id);
|
tcx.type_of(def_id);
|
||||||
tcx.impl_trait_ref(def_id);
|
tcx.impl_trait_ref(def_id);
|
||||||
tcx.item_predicates(def_id);
|
tcx.predicates_of(def_id);
|
||||||
},
|
},
|
||||||
hir::ItemTrait(..) => {
|
hir::ItemTrait(..) => {
|
||||||
tcx.item_generics(def_id);
|
tcx.generics_of(def_id);
|
||||||
tcx.lookup_trait_def(def_id);
|
tcx.trait_def(def_id);
|
||||||
ty::queries::super_predicates::get(tcx, it.span, def_id);
|
tcx.at(it.span).super_predicates_of(def_id);
|
||||||
tcx.item_predicates(def_id);
|
tcx.predicates_of(def_id);
|
||||||
},
|
},
|
||||||
hir::ItemStruct(ref struct_def, _) |
|
hir::ItemStruct(ref struct_def, _) |
|
||||||
hir::ItemUnion(ref struct_def, _) => {
|
hir::ItemUnion(ref struct_def, _) => {
|
||||||
tcx.item_generics(def_id);
|
tcx.generics_of(def_id);
|
||||||
tcx.item_type(def_id);
|
tcx.type_of(def_id);
|
||||||
tcx.item_predicates(def_id);
|
tcx.predicates_of(def_id);
|
||||||
|
|
||||||
for f in struct_def.fields() {
|
for f in struct_def.fields() {
|
||||||
let def_id = tcx.hir.local_def_id(f.id);
|
let def_id = tcx.hir.local_def_id(f.id);
|
||||||
tcx.item_generics(def_id);
|
tcx.generics_of(def_id);
|
||||||
tcx.item_type(def_id);
|
tcx.type_of(def_id);
|
||||||
tcx.item_predicates(def_id);
|
tcx.predicates_of(def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if !struct_def.is_struct() {
|
if !struct_def.is_struct() {
|
||||||
|
@ -497,14 +497,14 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
|
||||||
},
|
},
|
||||||
hir::ItemTy(_, ref generics) => {
|
hir::ItemTy(_, ref generics) => {
|
||||||
ensure_no_ty_param_bounds(tcx, it.span, generics, "type");
|
ensure_no_ty_param_bounds(tcx, it.span, generics, "type");
|
||||||
tcx.item_generics(def_id);
|
tcx.generics_of(def_id);
|
||||||
tcx.item_type(def_id);
|
tcx.type_of(def_id);
|
||||||
tcx.item_predicates(def_id);
|
tcx.predicates_of(def_id);
|
||||||
}
|
}
|
||||||
hir::ItemStatic(..) | hir::ItemConst(..) | hir::ItemFn(..) => {
|
hir::ItemStatic(..) | hir::ItemConst(..) | hir::ItemFn(..) => {
|
||||||
tcx.item_generics(def_id);
|
tcx.generics_of(def_id);
|
||||||
tcx.item_type(def_id);
|
tcx.type_of(def_id);
|
||||||
tcx.item_predicates(def_id);
|
tcx.predicates_of(def_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -512,40 +512,40 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
|
||||||
fn convert_trait_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_item_id: ast::NodeId) {
|
fn convert_trait_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_item_id: ast::NodeId) {
|
||||||
let trait_item = tcx.hir.expect_trait_item(trait_item_id);
|
let trait_item = tcx.hir.expect_trait_item(trait_item_id);
|
||||||
let def_id = tcx.hir.local_def_id(trait_item.id);
|
let def_id = tcx.hir.local_def_id(trait_item.id);
|
||||||
tcx.item_generics(def_id);
|
tcx.generics_of(def_id);
|
||||||
|
|
||||||
match trait_item.node {
|
match trait_item.node {
|
||||||
hir::TraitItemKind::Const(..) |
|
hir::TraitItemKind::Const(..) |
|
||||||
hir::TraitItemKind::Type(_, Some(_)) |
|
hir::TraitItemKind::Type(_, Some(_)) |
|
||||||
hir::TraitItemKind::Method(..) => {
|
hir::TraitItemKind::Method(..) => {
|
||||||
tcx.item_type(def_id);
|
tcx.type_of(def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::TraitItemKind::Type(_, None) => {}
|
hir::TraitItemKind::Type(_, None) => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
tcx.item_predicates(def_id);
|
tcx.predicates_of(def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert_impl_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_item_id: ast::NodeId) {
|
fn convert_impl_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_item_id: ast::NodeId) {
|
||||||
let def_id = tcx.hir.local_def_id(impl_item_id);
|
let def_id = tcx.hir.local_def_id(impl_item_id);
|
||||||
tcx.item_generics(def_id);
|
tcx.generics_of(def_id);
|
||||||
tcx.item_type(def_id);
|
tcx.type_of(def_id);
|
||||||
tcx.item_predicates(def_id);
|
tcx.predicates_of(def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert_variant_ctor<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn convert_variant_ctor<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
ctor_id: ast::NodeId) {
|
ctor_id: ast::NodeId) {
|
||||||
let def_id = tcx.hir.local_def_id(ctor_id);
|
let def_id = tcx.hir.local_def_id(ctor_id);
|
||||||
tcx.item_generics(def_id);
|
tcx.generics_of(def_id);
|
||||||
tcx.item_type(def_id);
|
tcx.type_of(def_id);
|
||||||
tcx.item_predicates(def_id);
|
tcx.predicates_of(def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert_enum_variant_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn convert_enum_variant_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
variants: &[hir::Variant]) {
|
variants: &[hir::Variant]) {
|
||||||
let def = tcx.lookup_adt_def(def_id);
|
let def = tcx.adt_def(def_id);
|
||||||
let repr_type = def.repr.discr_type();
|
let repr_type = def.repr.discr_type();
|
||||||
let initial = repr_type.initial_discriminant(tcx);
|
let initial = repr_type.initial_discriminant(tcx);
|
||||||
let mut prev_discr = None::<ConstInt>;
|
let mut prev_discr = None::<ConstInt>;
|
||||||
|
@ -556,7 +556,7 @@ fn convert_enum_variant_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
prev_discr = Some(if let Some(e) = variant.node.disr_expr {
|
prev_discr = Some(if let Some(e) = variant.node.disr_expr {
|
||||||
let expr_did = tcx.hir.local_def_id(e.node_id);
|
let expr_did = tcx.hir.local_def_id(e.node_id);
|
||||||
let substs = Substs::empty();
|
let substs = Substs::empty();
|
||||||
let result = ty::queries::const_eval::get(tcx, variant.span, (expr_did, substs));
|
let result = tcx.at(variant.span).const_eval((expr_did, substs));
|
||||||
|
|
||||||
// enum variant evaluation happens before the global constant check
|
// enum variant evaluation happens before the global constant check
|
||||||
// so we need to report the real error
|
// so we need to report the real error
|
||||||
|
@ -583,9 +583,9 @@ fn convert_enum_variant_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
for f in variant.node.data.fields() {
|
for f in variant.node.data.fields() {
|
||||||
let def_id = tcx.hir.local_def_id(f.id);
|
let def_id = tcx.hir.local_def_id(f.id);
|
||||||
tcx.item_generics(def_id);
|
tcx.generics_of(def_id);
|
||||||
tcx.item_type(def_id);
|
tcx.type_of(def_id);
|
||||||
tcx.item_predicates(def_id);
|
tcx.predicates_of(def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the ctor, if any. This also registers the variant as
|
// Convert the ctor, if any. This also registers the variant as
|
||||||
|
@ -686,9 +686,9 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
/// Ensures that the super-predicates of the trait with def-id
|
/// Ensures that the super-predicates of the trait with def-id
|
||||||
/// trait_def_id are converted and stored. This also ensures that
|
/// trait_def_id are converted and stored. This also ensures that
|
||||||
/// the transitive super-predicates are converted;
|
/// the transitive super-predicates are converted;
|
||||||
fn super_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn super_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
trait_def_id: DefId)
|
trait_def_id: DefId)
|
||||||
-> ty::GenericPredicates<'tcx> {
|
-> ty::GenericPredicates<'tcx> {
|
||||||
debug!("super_predicates(trait_def_id={:?})", trait_def_id);
|
debug!("super_predicates(trait_def_id={:?})", trait_def_id);
|
||||||
let trait_node_id = tcx.hir.as_local_node_id(trait_def_id).unwrap();
|
let trait_node_id = tcx.hir.as_local_node_id(trait_def_id).unwrap();
|
||||||
|
|
||||||
|
@ -725,7 +725,7 @@ fn super_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
// Now require that immediate supertraits are converted,
|
// Now require that immediate supertraits are converted,
|
||||||
// which will, in turn, reach indirect supertraits.
|
// which will, in turn, reach indirect supertraits.
|
||||||
for bound in superbounds.iter().filter_map(|p| p.to_opt_poly_trait_ref()) {
|
for bound in superbounds.iter().filter_map(|p| p.to_opt_poly_trait_ref()) {
|
||||||
ty::queries::super_predicates::get(tcx, item.span, bound.def_id());
|
tcx.at(item.span).super_predicates_of(bound.def_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::GenericPredicates {
|
ty::GenericPredicates {
|
||||||
|
@ -767,9 +767,9 @@ fn trait_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
tcx.alloc_trait_def(def)
|
tcx.alloc_trait_def(def)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
def_id: DefId)
|
def_id: DefId)
|
||||||
-> &'tcx ty::Generics {
|
-> &'tcx ty::Generics {
|
||||||
use rustc::hir::map::*;
|
use rustc::hir::map::*;
|
||||||
use rustc::hir::*;
|
use rustc::hir::*;
|
||||||
|
|
||||||
|
@ -873,7 +873,7 @@ fn generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
let mut parent_has_self = false;
|
let mut parent_has_self = false;
|
||||||
let mut own_start = has_self as u32;
|
let mut own_start = has_self as u32;
|
||||||
let (parent_regions, parent_types) = parent_def_id.map_or((0, 0), |def_id| {
|
let (parent_regions, parent_types) = parent_def_id.map_or((0, 0), |def_id| {
|
||||||
let generics = tcx.item_generics(def_id);
|
let generics = tcx.generics_of(def_id);
|
||||||
assert_eq!(has_self, false);
|
assert_eq!(has_self, false);
|
||||||
parent_has_self = generics.has_self;
|
parent_has_self = generics.has_self;
|
||||||
own_start = generics.count() as u32;
|
own_start = generics.count() as u32;
|
||||||
|
@ -958,9 +958,9 @@ fn generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
def_id: DefId)
|
def_id: DefId)
|
||||||
-> Ty<'tcx> {
|
-> Ty<'tcx> {
|
||||||
use rustc::hir::map::*;
|
use rustc::hir::map::*;
|
||||||
use rustc::hir::*;
|
use rustc::hir::*;
|
||||||
|
|
||||||
|
@ -1017,7 +1017,7 @@ fn ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
ItemEnum(..) |
|
ItemEnum(..) |
|
||||||
ItemStruct(..) |
|
ItemStruct(..) |
|
||||||
ItemUnion(..) => {
|
ItemUnion(..) => {
|
||||||
let def = tcx.lookup_adt_def(def_id);
|
let def = tcx.adt_def(def_id);
|
||||||
let substs = Substs::identity_for_item(tcx, def_id);
|
let substs = Substs::identity_for_item(tcx, def_id);
|
||||||
tcx.mk_adt(def, substs)
|
tcx.mk_adt(def, substs)
|
||||||
}
|
}
|
||||||
|
@ -1049,12 +1049,12 @@ fn ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
NodeStructCtor(&ref def) |
|
NodeStructCtor(&ref def) |
|
||||||
NodeVariant(&Spanned { node: hir::Variant_ { data: ref def, .. }, .. }) => {
|
NodeVariant(&Spanned { node: hir::Variant_ { data: ref def, .. }, .. }) => {
|
||||||
let ty = tcx.item_type(tcx.hir.get_parent_did(node_id));
|
let ty = tcx.type_of(tcx.hir.get_parent_did(node_id));
|
||||||
match *def {
|
match *def {
|
||||||
VariantData::Unit(..) | VariantData::Struct(..) => ty,
|
VariantData::Unit(..) | VariantData::Struct(..) => ty,
|
||||||
VariantData::Tuple(ref fields, _) => {
|
VariantData::Tuple(ref fields, _) => {
|
||||||
let inputs = fields.iter().map(|f| {
|
let inputs = fields.iter().map(|f| {
|
||||||
tcx.item_type(tcx.hir.local_def_id(f.id))
|
tcx.type_of(tcx.hir.local_def_id(f.id))
|
||||||
});
|
});
|
||||||
let substs = Substs::identity_for_item(tcx, def_id);
|
let substs = Substs::identity_for_item(tcx, def_id);
|
||||||
tcx.mk_fn_def(def_id, substs, ty::Binder(tcx.mk_fn_sig(
|
tcx.mk_fn_def(def_id, substs, ty::Binder(tcx.mk_fn_sig(
|
||||||
|
@ -1089,7 +1089,7 @@ fn ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
NodeVariant(&Spanned { node: Variant_ { disr_expr: Some(e), .. }, .. })
|
NodeVariant(&Spanned { node: Variant_ { disr_expr: Some(e), .. }, .. })
|
||||||
if e.node_id == node_id => {
|
if e.node_id == node_id => {
|
||||||
tcx.lookup_adt_def(tcx.hir.get_parent_did(node_id))
|
tcx.adt_def(tcx.hir.get_parent_did(node_id))
|
||||||
.repr.discr_type().to_ty(tcx)
|
.repr.discr_type().to_ty(tcx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1104,7 +1104,7 @@ fn ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
NodeTy(&hir::Ty { node: TyImplTrait(..), .. }) => {
|
NodeTy(&hir::Ty { node: TyImplTrait(..), .. }) => {
|
||||||
let owner = tcx.hir.get_parent_did(node_id);
|
let owner = tcx.hir.get_parent_did(node_id);
|
||||||
tcx.item_tables(owner).node_id_to_type(node_id)
|
tcx.typeck_tables_of(owner).node_id_to_type(node_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
x => {
|
x => {
|
||||||
|
@ -1127,7 +1127,7 @@ fn impl_trait_ref<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
}
|
}
|
||||||
hir::ItemImpl(.., ref opt_trait_ref, _, _) => {
|
hir::ItemImpl(.., ref opt_trait_ref, _, _) => {
|
||||||
opt_trait_ref.as_ref().map(|ast_trait_ref| {
|
opt_trait_ref.as_ref().map(|ast_trait_ref| {
|
||||||
let selfty = tcx.item_type(def_id);
|
let selfty = tcx.type_of(def_id);
|
||||||
AstConv::instantiate_mono_trait_ref(&icx, ast_trait_ref, selfty)
|
AstConv::instantiate_mono_trait_ref(&icx, ast_trait_ref, selfty)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1141,7 +1141,7 @@ fn impl_polarity<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||||
match tcx.hir.expect_item(node_id).node {
|
match tcx.hir.expect_item(node_id).node {
|
||||||
hir::ItemImpl(_, polarity, ..) => polarity,
|
hir::ItemImpl(_, polarity, ..) => polarity,
|
||||||
ref item => bug!("trait_impl_polarity: {:?} not an impl", item)
|
ref item => bug!("impl_polarity: {:?} not an impl", item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1205,9 +1205,9 @@ fn early_bound_lifetimes_from_generics<'a, 'tcx>(
|
||||||
.filter(move |l| !tcx.named_region_map.late_bound.contains(&l.lifetime.id))
|
.filter(move |l| !tcx.named_region_map.late_bound.contains(&l.lifetime.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
def_id: DefId)
|
def_id: DefId)
|
||||||
-> ty::GenericPredicates<'tcx> {
|
-> ty::GenericPredicates<'tcx> {
|
||||||
use rustc::hir::map::*;
|
use rustc::hir::map::*;
|
||||||
use rustc::hir::*;
|
use rustc::hir::*;
|
||||||
|
|
||||||
|
@ -1280,7 +1280,7 @@ fn predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
_ => &no_generics
|
_ => &no_generics
|
||||||
};
|
};
|
||||||
|
|
||||||
let generics = tcx.item_generics(def_id);
|
let generics = tcx.generics_of(def_id);
|
||||||
let parent_count = generics.parent_count() as u32;
|
let parent_count = generics.parent_count() as u32;
|
||||||
let has_own_self = generics.has_self && parent_count == 0;
|
let has_own_self = generics.has_self && parent_count == 0;
|
||||||
|
|
||||||
|
@ -1291,7 +1291,7 @@ fn predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
// on a trait we need to add in the supertrait bounds and bounds found on
|
// on a trait we need to add in the supertrait bounds and bounds found on
|
||||||
// associated types.
|
// associated types.
|
||||||
if let Some((trait_ref, _)) = is_trait {
|
if let Some((trait_ref, _)) = is_trait {
|
||||||
predicates = tcx.item_super_predicates(def_id).predicates;
|
predicates = tcx.super_predicates_of(def_id).predicates;
|
||||||
|
|
||||||
// Add in a predicate that `Self:Trait` (where `Trait` is the
|
// Add in a predicate that `Self:Trait` (where `Trait` is the
|
||||||
// current trait). This is needed for builtin bounds.
|
// current trait). This is needed for builtin bounds.
|
||||||
|
@ -1410,7 +1410,7 @@ fn predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
// in trait checking. See `setup_constraining_predicates`
|
// in trait checking. See `setup_constraining_predicates`
|
||||||
// for details.
|
// for details.
|
||||||
if let NodeItem(&Item { node: ItemImpl(..), .. }) = node {
|
if let NodeItem(&Item { node: ItemImpl(..), .. }) = node {
|
||||||
let self_ty = tcx.item_type(def_id);
|
let self_ty = tcx.type_of(def_id);
|
||||||
let trait_ref = tcx.impl_trait_ref(def_id);
|
let trait_ref = tcx.impl_trait_ref(def_id);
|
||||||
ctp::setup_constraining_predicates(&mut predicates,
|
ctp::setup_constraining_predicates(&mut predicates,
|
||||||
trait_ref,
|
trait_ref,
|
||||||
|
|
|
@ -95,9 +95,9 @@ fn enforce_impl_params_are_constrained<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
impl_item_refs: &[hir::ImplItemRef])
|
impl_item_refs: &[hir::ImplItemRef])
|
||||||
{
|
{
|
||||||
// Every lifetime used in an associated type must be constrained.
|
// Every lifetime used in an associated type must be constrained.
|
||||||
let impl_self_ty = tcx.item_type(impl_def_id);
|
let impl_self_ty = tcx.type_of(impl_def_id);
|
||||||
let impl_generics = tcx.item_generics(impl_def_id);
|
let impl_generics = tcx.generics_of(impl_def_id);
|
||||||
let impl_predicates = tcx.item_predicates(impl_def_id);
|
let impl_predicates = tcx.predicates_of(impl_def_id);
|
||||||
let impl_trait_ref = tcx.impl_trait_ref(impl_def_id);
|
let impl_trait_ref = tcx.impl_trait_ref(impl_def_id);
|
||||||
|
|
||||||
let mut input_parameters = ctp::parameters_for_impl(impl_self_ty, impl_trait_ref);
|
let mut input_parameters = ctp::parameters_for_impl(impl_self_ty, impl_trait_ref);
|
||||||
|
@ -120,7 +120,7 @@ fn enforce_impl_params_are_constrained<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
item.kind == ty::AssociatedKind::Type && item.defaultness.has_value()
|
item.kind == ty::AssociatedKind::Type && item.defaultness.has_value()
|
||||||
})
|
})
|
||||||
.flat_map(|def_id| {
|
.flat_map(|def_id| {
|
||||||
ctp::parameters_for(&tcx.item_type(def_id), true)
|
ctp::parameters_for(&tcx.type_of(def_id), true)
|
||||||
}).collect();
|
}).collect();
|
||||||
for (ty_lifetime, lifetime) in impl_generics.regions.iter()
|
for (ty_lifetime, lifetime) in impl_generics.regions.iter()
|
||||||
.zip(&impl_hir_generics.lifetimes)
|
.zip(&impl_hir_generics.lifetimes)
|
||||||
|
|
|
@ -179,7 +179,7 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
main_id: ast::NodeId,
|
main_id: ast::NodeId,
|
||||||
main_span: Span) {
|
main_span: Span) {
|
||||||
let main_def_id = tcx.hir.local_def_id(main_id);
|
let main_def_id = tcx.hir.local_def_id(main_id);
|
||||||
let main_t = tcx.item_type(main_def_id);
|
let main_t = tcx.type_of(main_def_id);
|
||||||
match main_t.sty {
|
match main_t.sty {
|
||||||
ty::TyFnDef(..) => {
|
ty::TyFnDef(..) => {
|
||||||
match tcx.hir.find(main_id) {
|
match tcx.hir.find(main_id) {
|
||||||
|
@ -229,7 +229,7 @@ fn check_start_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
start_id: ast::NodeId,
|
start_id: ast::NodeId,
|
||||||
start_span: Span) {
|
start_span: Span) {
|
||||||
let start_def_id = tcx.hir.local_def_id(start_id);
|
let start_def_id = tcx.hir.local_def_id(start_id);
|
||||||
let start_t = tcx.item_type(start_def_id);
|
let start_t = tcx.type_of(start_def_id);
|
||||||
match start_t.sty {
|
match start_t.sty {
|
||||||
ty::TyFnDef(..) => {
|
ty::TyFnDef(..) => {
|
||||||
match tcx.hir.find(start_id) {
|
match tcx.hir.find(start_id) {
|
||||||
|
|
|
@ -81,7 +81,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> {
|
||||||
hir::ItemEnum(..) |
|
hir::ItemEnum(..) |
|
||||||
hir::ItemStruct(..) |
|
hir::ItemStruct(..) |
|
||||||
hir::ItemUnion(..) => {
|
hir::ItemUnion(..) => {
|
||||||
let generics = tcx.item_generics(did);
|
let generics = tcx.generics_of(did);
|
||||||
|
|
||||||
// Not entirely obvious: constraints on structs/enums do not
|
// Not entirely obvious: constraints on structs/enums do not
|
||||||
// affect the variance of their type parameters. See discussion
|
// affect the variance of their type parameters. See discussion
|
||||||
|
@ -89,14 +89,14 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> {
|
||||||
//
|
//
|
||||||
// self.add_constraints_from_generics(generics);
|
// self.add_constraints_from_generics(generics);
|
||||||
|
|
||||||
for field in tcx.lookup_adt_def(did).all_fields() {
|
for field in tcx.adt_def(did).all_fields() {
|
||||||
self.add_constraints_from_ty(generics,
|
self.add_constraints_from_ty(generics,
|
||||||
tcx.item_type(field.did),
|
tcx.type_of(field.did),
|
||||||
self.covariant);
|
self.covariant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ItemTrait(..) => {
|
hir::ItemTrait(..) => {
|
||||||
let generics = tcx.item_generics(did);
|
let generics = tcx.generics_of(did);
|
||||||
let trait_ref = ty::TraitRef {
|
let trait_ref = ty::TraitRef {
|
||||||
def_id: did,
|
def_id: did,
|
||||||
substs: Substs::identity_for_item(tcx, did)
|
substs: Substs::identity_for_item(tcx, did)
|
||||||
|
@ -233,7 +233,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
// Parameter on an item defined within another crate:
|
// Parameter on an item defined within another crate:
|
||||||
// variance already inferred, just look it up.
|
// variance already inferred, just look it up.
|
||||||
let variances = self.tcx().item_variances(item_def_id);
|
let variances = self.tcx().variances_of(item_def_id);
|
||||||
self.constant_term(variances[index])
|
self.constant_term(variances[index])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,10 +286,10 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||||
trait_ref,
|
trait_ref,
|
||||||
variance);
|
variance);
|
||||||
|
|
||||||
let trait_generics = self.tcx().item_generics(trait_ref.def_id);
|
let trait_generics = self.tcx().generics_of(trait_ref.def_id);
|
||||||
|
|
||||||
// This edge is actually implied by the call to
|
// This edge is actually implied by the call to
|
||||||
// `lookup_trait_def`, but I'm trying to be future-proof. See
|
// `trait_def`, but I'm trying to be future-proof. See
|
||||||
// README.md for a discussion on dep-graph management.
|
// README.md for a discussion on dep-graph management.
|
||||||
self.tcx().dep_graph.read(VarianceDepNode(trait_ref.def_id));
|
self.tcx().dep_graph.read(VarianceDepNode(trait_ref.def_id));
|
||||||
|
|
||||||
|
@ -345,10 +345,10 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::TyAdt(def, substs) => {
|
ty::TyAdt(def, substs) => {
|
||||||
let adt_generics = self.tcx().item_generics(def.did);
|
let adt_generics = self.tcx().generics_of(def.did);
|
||||||
|
|
||||||
// This edge is actually implied by the call to
|
// This edge is actually implied by the call to
|
||||||
// `lookup_trait_def`, but I'm trying to be future-proof. See
|
// `trait_def`, but I'm trying to be future-proof. See
|
||||||
// README.md for a discussion on dep-graph management.
|
// README.md for a discussion on dep-graph management.
|
||||||
self.tcx().dep_graph.read(VarianceDepNode(def.did));
|
self.tcx().dep_graph.read(VarianceDepNode(def.did));
|
||||||
|
|
||||||
|
@ -362,10 +362,10 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||||
|
|
||||||
ty::TyProjection(ref data) => {
|
ty::TyProjection(ref data) => {
|
||||||
let trait_ref = &data.trait_ref;
|
let trait_ref = &data.trait_ref;
|
||||||
let trait_generics = self.tcx().item_generics(trait_ref.def_id);
|
let trait_generics = self.tcx().generics_of(trait_ref.def_id);
|
||||||
|
|
||||||
// This edge is actually implied by the call to
|
// This edge is actually implied by the call to
|
||||||
// `lookup_trait_def`, but I'm trying to be future-proof. See
|
// `trait_def`, but I'm trying to be future-proof. See
|
||||||
// README.md for a discussion on dep-graph management.
|
// README.md for a discussion on dep-graph management.
|
||||||
self.tcx().dep_graph.read(VarianceDepNode(trait_ref.def_id));
|
self.tcx().dep_graph.read(VarianceDepNode(trait_ref.def_id));
|
||||||
|
|
||||||
|
|
|
@ -137,8 +137,7 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> {
|
||||||
item_variances);
|
item_variances);
|
||||||
}
|
}
|
||||||
|
|
||||||
tcx.maps.variances
|
tcx.maps.variances_of.borrow_mut()
|
||||||
.borrow_mut()
|
|
||||||
.insert(item_def_id, Rc::new(item_variances));
|
.insert(item_def_id, Rc::new(item_variances));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,8 +178,7 @@ impl<'a, 'tcx> TermsContext<'a, 'tcx> {
|
||||||
// parameters".
|
// parameters".
|
||||||
if self.num_inferred() == inferreds_on_entry {
|
if self.num_inferred() == inferreds_on_entry {
|
||||||
let item_def_id = self.tcx.hir.local_def_id(item_id);
|
let item_def_id = self.tcx.hir.local_def_id(item_id);
|
||||||
self.tcx.maps.variances
|
self.tcx.maps.variances_of.borrow_mut()
|
||||||
.borrow_mut()
|
|
||||||
.insert(item_def_id, self.empty_variances.clone());
|
.insert(item_def_id, self.empty_variances.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ use std::io;
|
||||||
use std::iter::once;
|
use std::iter::once;
|
||||||
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax_pos::DUMMY_SP;
|
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
|
|
||||||
use rustc::hir::def::{Def, CtorKind};
|
use rustc::hir::def::{Def, CtorKind};
|
||||||
|
@ -152,12 +151,12 @@ pub fn record_extern_fqn(cx: &DocContext, did: DefId, kind: clean::TypeKind) {
|
||||||
|
|
||||||
pub fn build_external_trait(cx: &DocContext, did: DefId) -> clean::Trait {
|
pub fn build_external_trait(cx: &DocContext, did: DefId) -> clean::Trait {
|
||||||
let trait_items = cx.tcx.associated_items(did).map(|item| item.clean(cx)).collect();
|
let trait_items = cx.tcx.associated_items(did).map(|item| item.clean(cx)).collect();
|
||||||
let predicates = cx.tcx.item_predicates(did);
|
let predicates = cx.tcx.predicates_of(did);
|
||||||
let generics = (cx.tcx.item_generics(did), &predicates).clean(cx);
|
let generics = (cx.tcx.generics_of(did), &predicates).clean(cx);
|
||||||
let generics = filter_non_trait_generics(did, generics);
|
let generics = filter_non_trait_generics(did, generics);
|
||||||
let (generics, supertrait_bounds) = separate_supertrait_bounds(generics);
|
let (generics, supertrait_bounds) = separate_supertrait_bounds(generics);
|
||||||
clean::Trait {
|
clean::Trait {
|
||||||
unsafety: cx.tcx.lookup_trait_def(did).unsafety,
|
unsafety: cx.tcx.trait_def(did).unsafety,
|
||||||
generics: generics,
|
generics: generics,
|
||||||
items: trait_items,
|
items: trait_items,
|
||||||
bounds: supertrait_bounds,
|
bounds: supertrait_bounds,
|
||||||
|
@ -165,7 +164,7 @@ pub fn build_external_trait(cx: &DocContext, did: DefId) -> clean::Trait {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_external_function(cx: &DocContext, did: DefId) -> clean::Function {
|
fn build_external_function(cx: &DocContext, did: DefId) -> clean::Function {
|
||||||
let sig = cx.tcx.item_type(did).fn_sig();
|
let sig = cx.tcx.type_of(did).fn_sig();
|
||||||
|
|
||||||
let constness = if cx.tcx.sess.cstore.is_const_fn(did) {
|
let constness = if cx.tcx.sess.cstore.is_const_fn(did) {
|
||||||
hir::Constness::Const
|
hir::Constness::Const
|
||||||
|
@ -173,10 +172,10 @@ fn build_external_function(cx: &DocContext, did: DefId) -> clean::Function {
|
||||||
hir::Constness::NotConst
|
hir::Constness::NotConst
|
||||||
};
|
};
|
||||||
|
|
||||||
let predicates = cx.tcx.item_predicates(did);
|
let predicates = cx.tcx.predicates_of(did);
|
||||||
clean::Function {
|
clean::Function {
|
||||||
decl: (did, sig).clean(cx),
|
decl: (did, sig).clean(cx),
|
||||||
generics: (cx.tcx.item_generics(did), &predicates).clean(cx),
|
generics: (cx.tcx.generics_of(did), &predicates).clean(cx),
|
||||||
unsafety: sig.unsafety(),
|
unsafety: sig.unsafety(),
|
||||||
constness: constness,
|
constness: constness,
|
||||||
abi: sig.abi(),
|
abi: sig.abi(),
|
||||||
|
@ -184,18 +183,18 @@ fn build_external_function(cx: &DocContext, did: DefId) -> clean::Function {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_enum(cx: &DocContext, did: DefId) -> clean::Enum {
|
fn build_enum(cx: &DocContext, did: DefId) -> clean::Enum {
|
||||||
let predicates = cx.tcx.item_predicates(did);
|
let predicates = cx.tcx.predicates_of(did);
|
||||||
|
|
||||||
clean::Enum {
|
clean::Enum {
|
||||||
generics: (cx.tcx.item_generics(did), &predicates).clean(cx),
|
generics: (cx.tcx.generics_of(did), &predicates).clean(cx),
|
||||||
variants_stripped: false,
|
variants_stripped: false,
|
||||||
variants: cx.tcx.lookup_adt_def(did).variants.clean(cx),
|
variants: cx.tcx.adt_def(did).variants.clean(cx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_struct(cx: &DocContext, did: DefId) -> clean::Struct {
|
fn build_struct(cx: &DocContext, did: DefId) -> clean::Struct {
|
||||||
let predicates = cx.tcx.item_predicates(did);
|
let predicates = cx.tcx.predicates_of(did);
|
||||||
let variant = cx.tcx.lookup_adt_def(did).struct_variant();
|
let variant = cx.tcx.adt_def(did).struct_variant();
|
||||||
|
|
||||||
clean::Struct {
|
clean::Struct {
|
||||||
struct_type: match variant.ctor_kind {
|
struct_type: match variant.ctor_kind {
|
||||||
|
@ -203,30 +202,30 @@ fn build_struct(cx: &DocContext, did: DefId) -> clean::Struct {
|
||||||
CtorKind::Fn => doctree::Tuple,
|
CtorKind::Fn => doctree::Tuple,
|
||||||
CtorKind::Const => doctree::Unit,
|
CtorKind::Const => doctree::Unit,
|
||||||
},
|
},
|
||||||
generics: (cx.tcx.item_generics(did), &predicates).clean(cx),
|
generics: (cx.tcx.generics_of(did), &predicates).clean(cx),
|
||||||
fields: variant.fields.clean(cx),
|
fields: variant.fields.clean(cx),
|
||||||
fields_stripped: false,
|
fields_stripped: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_union(cx: &DocContext, did: DefId) -> clean::Union {
|
fn build_union(cx: &DocContext, did: DefId) -> clean::Union {
|
||||||
let predicates = cx.tcx.item_predicates(did);
|
let predicates = cx.tcx.predicates_of(did);
|
||||||
let variant = cx.tcx.lookup_adt_def(did).struct_variant();
|
let variant = cx.tcx.adt_def(did).struct_variant();
|
||||||
|
|
||||||
clean::Union {
|
clean::Union {
|
||||||
struct_type: doctree::Plain,
|
struct_type: doctree::Plain,
|
||||||
generics: (cx.tcx.item_generics(did), &predicates).clean(cx),
|
generics: (cx.tcx.generics_of(did), &predicates).clean(cx),
|
||||||
fields: variant.fields.clean(cx),
|
fields: variant.fields.clean(cx),
|
||||||
fields_stripped: false,
|
fields_stripped: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_type_alias(cx: &DocContext, did: DefId) -> clean::Typedef {
|
fn build_type_alias(cx: &DocContext, did: DefId) -> clean::Typedef {
|
||||||
let predicates = cx.tcx.item_predicates(did);
|
let predicates = cx.tcx.predicates_of(did);
|
||||||
|
|
||||||
clean::Typedef {
|
clean::Typedef {
|
||||||
type_: cx.tcx.item_type(did).clean(cx),
|
type_: cx.tcx.type_of(did).clean(cx),
|
||||||
generics: (cx.tcx.item_generics(did), &predicates).clean(cx),
|
generics: (cx.tcx.generics_of(did), &predicates).clean(cx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +233,7 @@ pub fn build_impls(cx: &DocContext, did: DefId) -> Vec<clean::Item> {
|
||||||
let tcx = cx.tcx;
|
let tcx = cx.tcx;
|
||||||
let mut impls = Vec::new();
|
let mut impls = Vec::new();
|
||||||
|
|
||||||
for &did in ty::queries::inherent_impls::get(tcx, DUMMY_SP, did).iter() {
|
for &did in tcx.inherent_impls(did).iter() {
|
||||||
build_impl(cx, did, &mut impls);
|
build_impl(cx, did, &mut impls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +325,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let for_ = tcx.item_type(did).clean(cx);
|
let for_ = tcx.type_of(did).clean(cx);
|
||||||
|
|
||||||
// Only inline impl if the implementing type is
|
// Only inline impl if the implementing type is
|
||||||
// reachable in rustdoc generated documentation
|
// reachable in rustdoc generated documentation
|
||||||
|
@ -336,7 +335,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let predicates = tcx.item_predicates(did);
|
let predicates = tcx.predicates_of(did);
|
||||||
let trait_items = tcx.associated_items(did).filter_map(|item| {
|
let trait_items = tcx.associated_items(did).filter_map(|item| {
|
||||||
match item.kind {
|
match item.kind {
|
||||||
ty::AssociatedKind::Const => {
|
ty::AssociatedKind::Const => {
|
||||||
|
@ -348,7 +347,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
|
||||||
Some(clean::Item {
|
Some(clean::Item {
|
||||||
name: Some(item.name.clean(cx)),
|
name: Some(item.name.clean(cx)),
|
||||||
inner: clean::AssociatedConstItem(
|
inner: clean::AssociatedConstItem(
|
||||||
tcx.item_type(item.def_id).clean(cx),
|
tcx.type_of(item.def_id).clean(cx),
|
||||||
default,
|
default,
|
||||||
),
|
),
|
||||||
source: tcx.def_span(item.def_id).clean(cx),
|
source: tcx.def_span(item.def_id).clean(cx),
|
||||||
|
@ -388,7 +387,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
|
||||||
}
|
}
|
||||||
ty::AssociatedKind::Type => {
|
ty::AssociatedKind::Type => {
|
||||||
let typedef = clean::Typedef {
|
let typedef = clean::Typedef {
|
||||||
type_: tcx.item_type(item.def_id).clean(cx),
|
type_: tcx.type_of(item.def_id).clean(cx),
|
||||||
generics: clean::Generics {
|
generics: clean::Generics {
|
||||||
lifetimes: vec![],
|
lifetimes: vec![],
|
||||||
type_params: vec![],
|
type_params: vec![],
|
||||||
|
@ -408,7 +407,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).collect::<Vec<_>>();
|
}).collect::<Vec<_>>();
|
||||||
let polarity = tcx.trait_impl_polarity(did);
|
let polarity = tcx.impl_polarity(did);
|
||||||
let trait_ = associated_trait.clean(cx).map(|bound| {
|
let trait_ = associated_trait.clean(cx).map(|bound| {
|
||||||
match bound {
|
match bound {
|
||||||
clean::TraitBound(polyt, _) => polyt.trait_,
|
clean::TraitBound(polyt, _) => polyt.trait_,
|
||||||
|
@ -432,7 +431,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
|
||||||
provided_trait_methods: provided,
|
provided_trait_methods: provided,
|
||||||
trait_: trait_,
|
trait_: trait_,
|
||||||
for_: for_,
|
for_: for_,
|
||||||
generics: (tcx.item_generics(did), &predicates).clean(cx),
|
generics: (tcx.generics_of(did), &predicates).clean(cx),
|
||||||
items: trait_items,
|
items: trait_items,
|
||||||
polarity: Some(polarity.clean(cx)),
|
polarity: Some(polarity.clean(cx)),
|
||||||
}),
|
}),
|
||||||
|
@ -496,14 +495,14 @@ fn print_inlined_const(cx: &DocContext, did: DefId) -> String {
|
||||||
|
|
||||||
fn build_const(cx: &DocContext, did: DefId) -> clean::Constant {
|
fn build_const(cx: &DocContext, did: DefId) -> clean::Constant {
|
||||||
clean::Constant {
|
clean::Constant {
|
||||||
type_: cx.tcx.item_type(did).clean(cx),
|
type_: cx.tcx.type_of(did).clean(cx),
|
||||||
expr: print_inlined_const(cx, did)
|
expr: print_inlined_const(cx, did)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_static(cx: &DocContext, did: DefId, mutable: bool) -> clean::Static {
|
fn build_static(cx: &DocContext, did: DefId, mutable: bool) -> clean::Static {
|
||||||
clean::Static {
|
clean::Static {
|
||||||
type_: cx.tcx.item_type(did).clean(cx),
|
type_: cx.tcx.type_of(did).clean(cx),
|
||||||
mutability: if mutable {clean::Mutable} else {clean::Immutable},
|
mutability: if mutable {clean::Mutable} else {clean::Immutable},
|
||||||
expr: "\n\n\n".to_string(), // trigger the "[definition]" links
|
expr: "\n\n\n".to_string(), // trigger the "[definition]" links
|
||||||
}
|
}
|
||||||
|
|
|
@ -606,7 +606,7 @@ impl<'tcx> Clean<TyParam> for ty::TypeParameterDef {
|
||||||
did: self.def_id,
|
did: self.def_id,
|
||||||
bounds: vec![], // these are filled in from the where-clauses
|
bounds: vec![], // these are filled in from the where-clauses
|
||||||
default: if self.has_default {
|
default: if self.has_default {
|
||||||
Some(cx.tcx.item_type(self.def_id).clean(cx))
|
Some(cx.tcx.type_of(self.def_id).clean(cx))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -1356,19 +1356,19 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
|
||||||
fn clean(&self, cx: &DocContext) -> Item {
|
fn clean(&self, cx: &DocContext) -> Item {
|
||||||
let inner = match self.kind {
|
let inner = match self.kind {
|
||||||
ty::AssociatedKind::Const => {
|
ty::AssociatedKind::Const => {
|
||||||
let ty = cx.tcx.item_type(self.def_id);
|
let ty = cx.tcx.type_of(self.def_id);
|
||||||
AssociatedConstItem(ty.clean(cx), None)
|
AssociatedConstItem(ty.clean(cx), None)
|
||||||
}
|
}
|
||||||
ty::AssociatedKind::Method => {
|
ty::AssociatedKind::Method => {
|
||||||
let generics = (cx.tcx.item_generics(self.def_id),
|
let generics = (cx.tcx.generics_of(self.def_id),
|
||||||
&cx.tcx.item_predicates(self.def_id)).clean(cx);
|
&cx.tcx.predicates_of(self.def_id)).clean(cx);
|
||||||
let sig = cx.tcx.item_type(self.def_id).fn_sig();
|
let sig = cx.tcx.type_of(self.def_id).fn_sig();
|
||||||
let mut decl = (self.def_id, sig).clean(cx);
|
let mut decl = (self.def_id, sig).clean(cx);
|
||||||
|
|
||||||
if self.method_has_self_argument {
|
if self.method_has_self_argument {
|
||||||
let self_ty = match self.container {
|
let self_ty = match self.container {
|
||||||
ty::ImplContainer(def_id) => {
|
ty::ImplContainer(def_id) => {
|
||||||
cx.tcx.item_type(def_id)
|
cx.tcx.type_of(def_id)
|
||||||
}
|
}
|
||||||
ty::TraitContainer(_) => cx.tcx.mk_self_type()
|
ty::TraitContainer(_) => cx.tcx.mk_self_type()
|
||||||
};
|
};
|
||||||
|
@ -1418,8 +1418,8 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
|
||||||
// are actually located on the trait/impl itself, so we need to load
|
// are actually located on the trait/impl itself, so we need to load
|
||||||
// all of the generics from there and then look for bounds that are
|
// all of the generics from there and then look for bounds that are
|
||||||
// applied to this associated type in question.
|
// applied to this associated type in question.
|
||||||
let predicates = cx.tcx.item_predicates(did);
|
let predicates = cx.tcx.predicates_of(did);
|
||||||
let generics = (cx.tcx.item_generics(did), &predicates).clean(cx);
|
let generics = (cx.tcx.generics_of(did), &predicates).clean(cx);
|
||||||
generics.where_predicates.iter().filter_map(|pred| {
|
generics.where_predicates.iter().filter_map(|pred| {
|
||||||
let (name, self_type, trait_, bounds) = match *pred {
|
let (name, self_type, trait_, bounds) = match *pred {
|
||||||
WherePredicate::BoundPredicate {
|
WherePredicate::BoundPredicate {
|
||||||
|
@ -1454,7 +1454,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
let ty = if self.defaultness.has_value() {
|
let ty = if self.defaultness.has_value() {
|
||||||
Some(cx.tcx.item_type(self.def_id))
|
Some(cx.tcx.type_of(self.def_id))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
@ -1922,9 +1922,9 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
|
||||||
ty::TyAnon(def_id, substs) => {
|
ty::TyAnon(def_id, substs) => {
|
||||||
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
|
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
|
||||||
// by looking up the projections associated with the def_id.
|
// by looking up the projections associated with the def_id.
|
||||||
let item_predicates = cx.tcx.item_predicates(def_id);
|
let predicates_of = cx.tcx.predicates_of(def_id);
|
||||||
let substs = cx.tcx.lift(&substs).unwrap();
|
let substs = cx.tcx.lift(&substs).unwrap();
|
||||||
let bounds = item_predicates.instantiate(cx.tcx, substs);
|
let bounds = predicates_of.instantiate(cx.tcx, substs);
|
||||||
ImplTrait(bounds.predicates.into_iter().filter_map(|predicate| {
|
ImplTrait(bounds.predicates.into_iter().filter_map(|predicate| {
|
||||||
predicate.to_opt_poly_trait_ref().clean(cx)
|
predicate.to_opt_poly_trait_ref().clean(cx)
|
||||||
}).collect())
|
}).collect())
|
||||||
|
@ -1963,7 +1963,7 @@ impl<'tcx> Clean<Item> for ty::FieldDef {
|
||||||
stability: get_stability(cx, self.did),
|
stability: get_stability(cx, self.did),
|
||||||
deprecation: get_deprecation(cx, self.did),
|
deprecation: get_deprecation(cx, self.did),
|
||||||
def_id: self.did,
|
def_id: self.did,
|
||||||
inner: StructFieldItem(cx.tcx.item_type(self.did).clean(cx)),
|
inner: StructFieldItem(cx.tcx.type_of(self.did).clean(cx)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2116,7 +2116,7 @@ impl<'tcx> Clean<Item> for ty::VariantDef {
|
||||||
CtorKind::Const => VariantKind::CLike,
|
CtorKind::Const => VariantKind::CLike,
|
||||||
CtorKind::Fn => {
|
CtorKind::Fn => {
|
||||||
VariantKind::Tuple(
|
VariantKind::Tuple(
|
||||||
self.fields.iter().map(|f| cx.tcx.item_type(f.did).clean(cx)).collect()
|
self.fields.iter().map(|f| cx.tcx.type_of(f.did).clean(cx)).collect()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
CtorKind::Fictive => {
|
CtorKind::Fictive => {
|
||||||
|
@ -2132,7 +2132,7 @@ impl<'tcx> Clean<Item> for ty::VariantDef {
|
||||||
def_id: field.did,
|
def_id: field.did,
|
||||||
stability: get_stability(cx, field.did),
|
stability: get_stability(cx, field.did),
|
||||||
deprecation: get_deprecation(cx, field.did),
|
deprecation: get_deprecation(cx, field.did),
|
||||||
inner: StructFieldItem(cx.tcx.item_type(field.did).clean(cx))
|
inner: StructFieldItem(cx.tcx.type_of(field.did).clean(cx))
|
||||||
}
|
}
|
||||||
}).collect()
|
}).collect()
|
||||||
})
|
})
|
||||||
|
|
|
@ -153,7 +153,7 @@ fn trait_is_same_or_supertrait(cx: &DocContext, child: DefId,
|
||||||
if child == trait_ {
|
if child == trait_ {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
let predicates = cx.tcx.item_super_predicates(child).predicates;
|
let predicates = cx.tcx.super_predicates_of(child).predicates;
|
||||||
predicates.iter().filter_map(|pred| {
|
predicates.iter().filter_map(|pred| {
|
||||||
if let ty::Predicate::Trait(ref pred) = *pred {
|
if let ty::Predicate::Trait(ref pred) = *pred {
|
||||||
if pred.0.trait_ref.self_ty().is_self() {
|
if pred.0.trait_ref.self_ty().is_self() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue