rustc: switch most remaining middle::ty functions to methods.

This commit is contained in:
Eduard Burtescu 2015-06-25 23:42:17 +03:00
parent 5cedd66a6c
commit ad66c215aa
92 changed files with 3726 additions and 4000 deletions

View file

@ -23,7 +23,6 @@ use metadata::cstore;
use metadata::decoder;
use metadata::tyencode;
use middle::def;
use middle::ty::lookup_item_type;
use middle::ty::{self, Ty};
use middle::stability;
use util::nodemap::{FnvHashMap, NodeMap, NodeSet};
@ -133,7 +132,7 @@ pub fn def_to_string(did: DefId) -> String {
fn encode_item_variances(rbml_w: &mut Encoder,
ecx: &EncodeContext,
id: NodeId) {
let v = ty::item_variances(ecx.tcx, ast_util::local_def(id));
let v = ecx.tcx.item_variances(ast_util::local_def(id));
rbml_w.start_tag(tag_item_variances);
v.encode(rbml_w);
rbml_w.end_tag();
@ -144,8 +143,8 @@ fn encode_bounds_and_type_for_item<'a, 'tcx>(rbml_w: &mut Encoder,
id: ast::NodeId) {
encode_bounds_and_type(rbml_w,
ecx,
&ty::lookup_item_type(ecx.tcx, local_def(id)),
&ty::lookup_predicates(ecx.tcx, local_def(id)));
&ecx.tcx.lookup_item_type(local_def(id)),
&ecx.tcx.lookup_predicates(local_def(id)));
}
fn encode_bounds_and_type<'a, 'tcx>(rbml_w: &mut Encoder,
@ -293,8 +292,7 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
let mut disr_val = 0;
let mut i = 0;
let vi = ty::enum_variants(ecx.tcx,
DefId { krate: ast::LOCAL_CRATE, node: id });
let vi = ecx.tcx.enum_variants(local_def(id));
for variant in variants {
let def_id = local_def(variant.node.id);
index.push(entry {
@ -319,7 +317,7 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
match variant.node.kind {
ast::TupleVariantKind(_) => {},
ast::StructVariantKind(_) => {
let fields = ty::lookup_struct_fields(ecx.tcx, def_id);
let fields = ecx.tcx.lookup_struct_fields(def_id);
let idx = encode_info_for_struct(ecx,
rbml_w,
&fields[..],
@ -328,9 +326,10 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
encode_index(rbml_w, idx, write_i64);
}
}
if (*vi)[i].disr_val != disr_val {
encode_disr_val(ecx, rbml_w, (*vi)[i].disr_val);
disr_val = (*vi)[i].disr_val;
let specified_disr_val = vi[i].disr_val;
if specified_disr_val != disr_val {
encode_disr_val(ecx, rbml_w, specified_disr_val);
disr_val = specified_disr_val;
}
encode_bounds_and_type_for_item(rbml_w, ecx, def_id.local_id());
@ -379,9 +378,7 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext,
Some(implementations) => {
for base_impl_did in implementations.iter() {
for &method_did in impl_items.get(base_impl_did).unwrap() {
let impl_item = ty::impl_or_trait_item(
ecx.tcx,
method_did.def_id());
let impl_item = ecx.tcx.impl_or_trait_item(method_did.def_id());
if let ty::MethodTraitItem(ref m) = impl_item {
encode_reexported_static_method(rbml_w,
exp,
@ -875,7 +872,7 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
if let Some(impl_item) = impl_item_opt {
if let ast::MethodImplItem(ref sig, _) = impl_item.node {
encode_attributes(rbml_w, &impl_item.attrs);
let scheme = ty::lookup_item_type(ecx.tcx, m.def_id);
let scheme = ecx.tcx.lookup_item_type(m.def_id);
let any_types = !scheme.generics.types.is_empty();
let needs_inline = any_types || is_default_impl ||
attr::requests_inline(&impl_item.attrs);
@ -923,7 +920,7 @@ fn encode_info_for_associated_type<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
encode_attributes(rbml_w, &ii.attrs);
} else {
encode_predicates(rbml_w, ecx,
&ty::lookup_predicates(ecx.tcx, associated_type.def_id),
&ecx.tcx.lookup_predicates(associated_type.def_id),
tag_item_generics);
}
@ -995,7 +992,7 @@ fn encode_extension_implementations(ecx: &EncodeContext,
rbml_w: &mut Encoder,
trait_def_id: DefId) {
assert!(ast_util::is_local(trait_def_id));
let def = ty::lookup_trait_def(ecx.tcx, trait_def_id);
let def = ecx.tcx.lookup_trait_def(trait_def_id);
def.for_each_impl(ecx.tcx, |impl_def_id| {
rbml_w.start_tag(tag_items_data_item_extension_impl);
@ -1161,7 +1158,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
index);
}
ast::ItemStruct(ref struct_def, _) => {
let fields = ty::lookup_struct_fields(tcx, def_id);
let fields = tcx.lookup_struct_fields(def_id);
/* First, encode the fields
These come first because we need to write them to make
@ -1220,7 +1217,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_name(rbml_w, item.ident.name);
encode_unsafety(rbml_w, unsafety);
let trait_ref = ty::impl_trait_ref(tcx, local_def(item.id)).unwrap();
let trait_ref = tcx.impl_trait_ref(local_def(item.id)).unwrap();
encode_trait_ref(rbml_w, ecx, trait_ref, tag_item_trait_ref);
rbml_w.end_tag();
}
@ -1274,7 +1271,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
}
rbml_w.end_tag();
}
if let Some(trait_ref) = ty::impl_trait_ref(tcx, local_def(item.id)) {
if let Some(trait_ref) = tcx.impl_trait_ref(local_def(item.id)) {
encode_trait_ref(rbml_w, ecx, trait_ref, tag_item_trait_ref);
}
encode_path(rbml_w, path.clone());
@ -1298,7 +1295,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
pos: rbml_w.mark_stable_position(),
});
match ty::impl_or_trait_item(tcx, trait_item_def_id.def_id()) {
match tcx.impl_or_trait_item(trait_item_def_id.def_id()) {
ty::ConstTraitItem(ref associated_const) => {
encode_info_for_associated_const(ecx,
rbml_w,
@ -1333,22 +1330,22 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_def_id(rbml_w, def_id);
encode_family(rbml_w, 'I');
encode_item_variances(rbml_w, ecx, item.id);
let trait_def = ty::lookup_trait_def(tcx, def_id);
let trait_predicates = ty::lookup_predicates(tcx, def_id);
let trait_def = tcx.lookup_trait_def(def_id);
let trait_predicates = tcx.lookup_predicates(def_id);
encode_unsafety(rbml_w, trait_def.unsafety);
encode_paren_sugar(rbml_w, trait_def.paren_sugar);
encode_defaulted(rbml_w, ty::trait_has_default_impl(tcx, def_id));
encode_defaulted(rbml_w, tcx.trait_has_default_impl(def_id));
encode_associated_type_names(rbml_w, &trait_def.associated_type_names);
encode_generics(rbml_w, ecx, &trait_def.generics, &trait_predicates,
tag_item_generics);
encode_predicates(rbml_w, ecx, &ty::lookup_super_predicates(tcx, def_id),
encode_predicates(rbml_w, ecx, &tcx.lookup_super_predicates(def_id),
tag_item_super_predicates);
encode_trait_ref(rbml_w, ecx, trait_def.trait_ref, tag_item_trait_ref);
encode_name(rbml_w, item.ident.name);
encode_attributes(rbml_w, &item.attrs);
encode_visibility(rbml_w, vis);
encode_stability(rbml_w, stab);
for &method_def_id in ty::trait_item_def_ids(tcx, def_id).iter() {
for &method_def_id in tcx.trait_item_def_ids(def_id).iter() {
rbml_w.start_tag(tag_item_trait_item);
match method_def_id {
ty::ConstTraitItemId(const_def_id) => {
@ -1380,7 +1377,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
rbml_w.end_tag();
// Now output the trait item info for each trait item.
let r = ty::trait_item_def_ids(tcx, def_id);
let r = tcx.trait_item_def_ids(def_id);
for (i, &item_def_id) in r.iter().enumerate() {
assert_eq!(item_def_id.def_id().krate, ast::LOCAL_CRATE);
@ -1397,7 +1394,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_stability(rbml_w, stab);
let trait_item_type =
ty::impl_or_trait_item(tcx, item_def_id.def_id());
tcx.impl_or_trait_item(item_def_id.def_id());
let is_nonstatic_method;
match trait_item_type {
ty::ConstTraitItem(associated_const) => {

View file

@ -413,7 +413,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
let method_call = ty::MethodCall::expr(call_expr.id);
let fn_ty = match self.tcx.method_map.borrow().get(&method_call) {
Some(method) => method.ty,
None => ty::expr_ty_adjusted(self.tcx, func_or_rcvr)
None => self.tcx.expr_ty_adjusted(func_or_rcvr)
};
let func_or_rcvr_exit = self.expr(func_or_rcvr, pred);

View file

@ -115,7 +115,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
{
let param_env = match item_id {
Some(item_id) => ty::ParameterEnvironment::for_item(self.tcx, item_id),
None => ty::empty_parameter_environment(self.tcx)
None => self.tcx.empty_parameter_environment()
};
f(&mut euv::ExprUseVisitor::new(self, &param_env))
}
@ -231,7 +231,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
fn_like.id());
self.add_qualif(qualif);
if ty::type_contents(self.tcx, ret_ty).interior_unsafe() {
if ret_ty.type_contents(self.tcx).interior_unsafe() {
self.add_qualif(ConstQualif::MUTABLE_MEM);
}
@ -266,8 +266,8 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
}
fn check_static_mut_type(&self, e: &ast::Expr) {
let node_ty = ty::node_id_to_type(self.tcx, e.id);
let tcontents = ty::type_contents(self.tcx, node_ty);
let node_ty = self.tcx.node_id_to_type(e.id);
let tcontents = node_ty.type_contents(self.tcx);
let suffix = if tcontents.has_dtor() {
"destructors"
@ -282,12 +282,12 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
}
fn check_static_type(&self, e: &ast::Expr) {
let ty = ty::node_id_to_type(self.tcx, e.id);
let ty = self.tcx.node_id_to_type(e.id);
let infcx = infer::new_infer_ctxt(self.tcx);
let mut fulfill_cx = traits::FulfillmentContext::new(false);
let cause = traits::ObligationCause::new(e.span, e.id, traits::SharedStatic);
fulfill_cx.register_builtin_bound(&infcx, ty, ty::BoundSync, cause);
let env = ty::empty_parameter_environment(self.tcx);
let env = self.tcx.empty_parameter_environment();
match fulfill_cx.select_all_or_error(&infcx, &env) {
Ok(()) => { },
Err(ref errors) => {
@ -402,7 +402,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
let mut outer = self.qualif;
self.qualif = ConstQualif::empty();
let node_ty = ty::node_id_to_type(self.tcx, ex.id);
let node_ty = self.tcx.node_id_to_type(ex.id);
check_expr(self, ex, node_ty);
// Special-case some expressions to avoid certain flags bubbling up.
@ -479,7 +479,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
// initializer values (very bad).
// If the type doesn't have interior mutability, then `ConstQualif::MUTABLE_MEM` has
// propagated from another error, so erroring again would be just noise.
let tc = ty::type_contents(self.tcx, node_ty);
let tc = node_ty.type_contents(self.tcx);
if self.qualif.intersects(ConstQualif::MUTABLE_MEM) && tc.interior_unsafe() {
outer = outer | ConstQualif::NOT_CONST;
if self.mode != Mode::Var {
@ -529,7 +529,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
e: &ast::Expr, node_ty: Ty<'tcx>) {
match node_ty.sty {
ty::TyStruct(did, _) |
ty::TyEnum(did, _) if ty::has_dtor(v.tcx, did) => {
ty::TyEnum(did, _) if v.tcx.has_dtor(did) => {
v.add_qualif(ConstQualif::NEEDS_DROP);
if v.mode != Mode::Var {
v.tcx.sess.span_err(e.span,
@ -560,7 +560,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
}
}
ast::ExprUnary(op, ref inner) => {
match ty::node_id_to_type(v.tcx, inner.id).sty {
match v.tcx.node_id_to_type(inner.id).sty {
ty::TyRawPtr(_) => {
assert!(op == ast::UnDeref);
@ -574,7 +574,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
}
}
ast::ExprBinary(op, ref lhs, _) => {
match ty::node_id_to_type(v.tcx, lhs.id).sty {
match v.tcx.node_id_to_type(lhs.id).sty {
ty::TyRawPtr(_) => {
assert!(op.node == ast::BiEq || op.node == ast::BiNe ||
op.node == ast::BiLe || op.node == ast::BiLt ||
@ -731,7 +731,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
ast::ExprClosure(..) => {
// Paths in constant contexts cannot refer to local variables,
// as there are none, and thus closures can't have upvars there.
if ty::with_freevars(v.tcx, e.id, |fv| !fv.is_empty()) {
if v.tcx.with_freevars(e.id, |fv| !fv.is_empty()) {
assert!(v.mode == Mode::Var,
"global closures can't capture anything");
v.add_qualif(ConstQualif::NOT_CONST);

View file

@ -20,7 +20,7 @@ use middle::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, Init};
use middle::expr_use_visitor::{JustWrite, LoanCause, MutateMode};
use middle::expr_use_visitor::WriteAndRead;
use middle::expr_use_visitor as euv;
use middle::mem_categorization::cmt;
use middle::mem_categorization::{cmt, Typer};
use middle::pat_util::*;
use middle::ty::*;
use middle::ty;
@ -149,7 +149,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MatchCheckCtxt<'a, 'tcx> {
pub fn check_crate(tcx: &ty::ctxt) {
visit::walk_crate(&mut MatchCheckCtxt {
tcx: tcx,
param_env: ty::empty_parameter_environment(tcx),
param_env: tcx.empty_parameter_environment(),
}, tcx.map.krate());
tcx.sess.abort_if_errors();
}
@ -203,9 +203,9 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
// Finally, check if the whole match expression is exhaustive.
// Check for empty enum, because is_useful only works on inhabited types.
let pat_ty = node_id_to_type(cx.tcx, scrut.id);
let pat_ty = cx.tcx.node_id_to_type(scrut.id);
if inlined_arms.is_empty() {
if !type_is_empty(cx.tcx, pat_ty) {
if !pat_ty.is_empty(cx.tcx) {
// We know the type is inhabited, so this must be wrong
span_err!(cx.tcx.sess, ex.span, E0002,
"non-exhaustive patterns: type {} is non-empty",
@ -231,11 +231,11 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
ast_util::walk_pat(pat, |p| {
match p.node {
ast::PatIdent(ast::BindByValue(ast::MutImmutable), ident, None) => {
let pat_ty = ty::pat_ty(cx.tcx, p);
let pat_ty = cx.tcx.pat_ty(p);
if let ty::TyEnum(def_id, _) = pat_ty.sty {
let def = cx.tcx.def_map.borrow().get(&p.id).map(|d| d.full_def());
if let Some(DefLocal(_)) = def {
if ty::enum_variants(cx.tcx, def_id).iter().any(|variant|
if cx.tcx.enum_variants(def_id).iter().any(|variant|
token::get_name(variant.name) == token::get_name(ident.node.name)
&& variant.args.is_empty()
) {
@ -509,12 +509,12 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
ty::TyEnum(cid, _) | ty::TyStruct(cid, _) => {
let (vid, is_structure) = match ctor {
&Variant(vid) =>
(vid, ty::enum_variant_with_id(cx.tcx, cid, vid).arg_names.is_some()),
(vid, cx.tcx.enum_variant_with_id(cid, vid).arg_names.is_some()),
_ =>
(cid, !ty::is_tuple_struct(cx.tcx, cid))
(cid, !cx.tcx.is_tuple_struct(cid))
};
if is_structure {
let fields = ty::lookup_struct_fields(cx.tcx, vid);
let fields = cx.tcx.lookup_struct_fields(vid);
let field_pats: Vec<_> = fields.into_iter()
.zip(pats)
.filter(|&(_, ref pat)| pat.node != ast::PatWild(ast::PatWildSingle))
@ -605,7 +605,7 @@ fn all_constructors(cx: &MatchCheckCtxt, left_ty: Ty,
},
ty::TyEnum(eid, _) =>
ty::enum_variants(cx.tcx, eid)
cx.tcx.enum_variants(eid)
.iter()
.map(|va| Variant(va.id))
.collect(),
@ -653,7 +653,7 @@ fn is_useful(cx: &MatchCheckCtxt,
let left_ty = if real_pat.id == DUMMY_NODE_ID {
cx.tcx.mk_nil()
} else {
let left_ty = ty::pat_ty(cx.tcx, &*real_pat);
let left_ty = cx.tcx.pat_ty(&*real_pat);
match real_pat.node {
ast::PatIdent(ast::BindByRef(..), _, _) => {
@ -817,11 +817,11 @@ pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> usi
},
ty::TyEnum(eid, _) => {
match *ctor {
Variant(id) => enum_variant_with_id(cx.tcx, eid, id).args.len(),
Variant(id) => cx.tcx.enum_variant_with_id(eid, id).args.len(),
_ => unreachable!()
}
}
ty::TyStruct(cid, _) => ty::lookup_struct_fields(cx.tcx, cid).len(),
ty::TyStruct(cid, _) => cx.tcx.lookup_struct_fields(cid).len(),
ty::TyArray(_, n) => n,
_ => 0
}
@ -913,7 +913,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
},
_ => {
// Assume this is a struct.
match ty::ty_to_def_id(node_id_to_type(cx.tcx, pat_id)) {
match cx.tcx.node_id_to_type(pat_id).ty_to_def_id() {
None => {
cx.tcx.sess.span_bug(pat_span,
"struct pattern wasn't of a \
@ -924,7 +924,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
}
};
class_id.map(|variant_id| {
let struct_fields = ty::lookup_struct_fields(cx.tcx, variant_id);
let struct_fields = cx.tcx.lookup_struct_fields(variant_id);
let args = struct_fields.iter().map(|sf| {
match pattern_fields.iter().find(|f| f.node.ident.name == sf.name) {
Some(ref f) => &*f.node.pat,
@ -1109,8 +1109,8 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
if pat_is_binding(def_map, &*p) {
match p.node {
ast::PatIdent(ast::BindByValue(_), _, ref sub) => {
let pat_ty = ty::node_id_to_type(tcx, p.id);
if ty::type_moves_by_default(&cx.param_env, pat.span, pat_ty) {
let pat_ty = tcx.node_id_to_type(p.id);
if cx.param_env.type_moves_by_default(pat_ty, pat.span) {
check_move(p, sub.as_ref().map(|p| &**p));
}
}

View file

@ -59,7 +59,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for RvalueContextDelegate<'a, 'tcx> {
cmt: mc::cmt<'tcx>,
_: euv::ConsumeMode) {
debug!("consume; cmt: {:?}; type: {:?}", *cmt, cmt.ty);
if !ty::type_is_sized(Some(self.param_env), self.tcx, span, cmt.ty) {
if !cmt.ty.is_sized(self.param_env, span) {
span_err!(self.tcx.sess, span, E0161,
"cannot move a value of type {0}: the size of {0} cannot be statically determined",
cmt.ty);

View file

@ -126,9 +126,9 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
// `resolve_trait_associated_const` will select an impl
// or the default.
Some(ref_id) => {
let trait_id = ty::trait_of_item(tcx, def_id)
let trait_id = tcx.trait_of_item(def_id)
.unwrap();
let substs = ty::node_id_item_substs(tcx, ref_id)
let substs = tcx.node_id_item_substs(ref_id)
.substs;
resolve_trait_associated_const(tcx, ti, trait_id,
substs)
@ -176,7 +176,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
// a trait-associated const if the caller gives us
// the expression that refers to it.
Some(ref_id) => {
let substs = ty::node_id_item_substs(tcx, ref_id)
let substs = tcx.node_id_item_substs(ref_id)
.substs;
resolve_trait_associated_const(tcx, ti, trait_id,
substs).map(|e| e.id)
@ -714,7 +714,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
e: &Expr,
ty_hint: Option<Ty<'tcx>>) -> EvalResult {
eval_const_expr_with_substs(tcx, e, ty_hint, |id| {
ty::node_id_item_substs(tcx, id).substs
tcx.node_id_item_substs(id).substs
})
}
@ -725,7 +725,7 @@ pub fn eval_const_expr_with_substs<'tcx, S>(tcx: &ty::ctxt<'tcx>,
where S: Fn(ast::NodeId) -> subst::Substs<'tcx> {
fn fromb(b: bool) -> ConstVal { Int(b as i64) }
let ety = ty_hint.or_else(|| ty::expr_ty_opt(tcx, e));
let ety = ty_hint.or_else(|| tcx.expr_ty_opt(e));
// If type of expression itself is int or uint, normalize in these
// bindings so that isize/usize is mapped to a type with an
@ -882,7 +882,7 @@ pub fn eval_const_expr_with_substs<'tcx, S>(tcx: &ty::ctxt<'tcx>,
// FIXME (#23833): the type-hint can cause problems,
// e.g. `(i8::MAX + 1_i8) as u32` feeds in `u32` as result
// type to the sum, and thus no overflow is signaled.
let base_hint = ty::expr_ty_opt(tcx, &**base).unwrap_or(ety);
let base_hint = tcx.expr_ty_opt(&**base).unwrap_or(ety);
let val = try!(eval_const_expr_partial(tcx, &**base, Some(base_hint)));
match cast_const(tcx, val, ety) {
Ok(val) => val,
@ -1030,10 +1030,10 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
let trait_ref = ty::Binder(ty::TraitRef { def_id: trait_id,
substs: trait_substs });
ty::populate_implementations_for_trait_if_necessary(tcx, trait_ref.def_id());
tcx.populate_implementations_for_trait_if_necessary(trait_ref.def_id());
let infcx = infer::new_infer_ctxt(tcx);
let param_env = ty::empty_parameter_environment(tcx);
let param_env = tcx.empty_parameter_environment();
let mut selcx = traits::SelectionContext::new(&infcx, &param_env);
let obligation = traits::Obligation::new(traits::ObligationCause::dummy(),
trait_ref.to_poly_trait_predicate());
@ -1056,7 +1056,7 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
match selection {
traits::VtableImpl(ref impl_data) => {
match ty::associated_consts(tcx, impl_data.impl_def_id)
match tcx.associated_consts(impl_data.impl_def_id)
.iter().find(|ic| ic.name == ti.ident.name) {
Some(ic) => lookup_const_by_id(tcx, ic.def_id, None),
None => match ti.node {

View file

@ -100,7 +100,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
Some(method) => {
match method.origin {
ty::MethodStatic(def_id) => {
match ty::provided_source(self.tcx, def_id) {
match self.tcx.provided_source(def_id) {
Some(p_did) => self.check_def_id(p_did),
None => self.check_def_id(def_id)
}
@ -116,9 +116,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
method_num: index,
..
}) => {
let trait_item = ty::trait_item(self.tcx,
trait_ref.def_id,
index);
let trait_item = self.tcx.trait_item(trait_ref.def_id, index);
self.check_def_id(trait_item.def_id());
}
}
@ -132,9 +130,9 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
}
fn handle_field_access(&mut self, lhs: &ast::Expr, name: ast::Name) {
match ty::expr_ty_adjusted(self.tcx, lhs).sty {
match self.tcx.expr_ty_adjusted(lhs).sty {
ty::TyStruct(id, _) => {
let fields = ty::lookup_struct_fields(self.tcx, id);
let fields = self.tcx.lookup_struct_fields(id);
let field_id = fields.iter()
.find(|field| field.name == name).unwrap().id;
self.live_symbols.insert(field_id.node);
@ -144,9 +142,9 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
}
fn handle_tup_field_access(&mut self, lhs: &ast::Expr, idx: usize) {
match ty::expr_ty_adjusted(self.tcx, lhs).sty {
match self.tcx.expr_ty_adjusted(lhs).sty {
ty::TyStruct(id, _) => {
let fields = ty::lookup_struct_fields(self.tcx, id);
let fields = self.tcx.lookup_struct_fields(id);
let field_id = fields[idx].id;
self.live_symbols.insert(field_id.node);
},
@ -159,8 +157,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
let id = match self.tcx.def_map.borrow().get(&lhs.id).unwrap().full_def() {
def::DefVariant(_, id, _) => id,
_ => {
match ty::ty_to_def_id(ty::node_id_to_type(self.tcx,
lhs.id)) {
match self.tcx.node_id_to_type(lhs.id).ty_to_def_id() {
None => {
self.tcx.sess.span_bug(lhs.span,
"struct pattern wasn't of a \
@ -170,7 +167,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
}
}
};
let fields = ty::lookup_struct_fields(self.tcx, id);
let fields = self.tcx.lookup_struct_fields(id);
for pat in pats {
if let ast::PatWild(ast::PatWildSingle) = pat.node.pat.node {
continue;
@ -480,8 +477,8 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
fn should_warn_about_field(&mut self, node: &ast::StructField_) -> bool {
let is_named = node.ident().is_some();
let field_type = ty::node_id_to_type(self.tcx, node.id);
let is_marker_field = match ty::ty_to_def_id(field_type) {
let field_type = self.tcx.node_id_to_type(node.id);
let is_marker_field = match field_type.ty_to_def_id() {
Some(def_id) => self.tcx.lang_items.items().any(|(_, item)| *item == Some(def_id)),
_ => false
};

View file

@ -62,7 +62,7 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> {
fn check_str_index(&mut self, e: &ast::Expr) {
let base_type = match e.node {
ast::ExprIndex(ref base, _) => ty::node_id_to_type(self.tcx, base.id),
ast::ExprIndex(ref base, _) => self.tcx.node_id_to_type(base.id),
_ => return
};
debug!("effect: checking index with base type {:?}",
@ -149,7 +149,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
}
}
ast::ExprCall(ref base, _) => {
let base_type = ty::node_id_to_type(self.tcx, base.id);
let base_type = self.tcx.node_id_to_type(base.id);
debug!("effect: call case, base type is {:?}",
base_type);
if type_is_unsafe_function(base_type) {
@ -157,7 +157,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
}
}
ast::ExprUnary(ast::UnDeref, ref base) => {
let base_type = ty::node_id_to_type(self.tcx, base.id);
let base_type = self.tcx.node_id_to_type(base.id);
debug!("effect: unary case, base type is {:?}",
base_type);
if let ty::TyRawPtr(_) = base_type.sty {
@ -174,7 +174,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
self.require_unsafe(expr.span, "use of inline assembly");
}
ast::ExprPath(..) => {
if let def::DefStatic(_, true) = ty::resolve_expr(self.tcx, expr) {
if let def::DefStatic(_, true) = self.tcx.resolve_expr(expr) {
self.require_unsafe(expr.span, "use of mutable static");
}
}

View file

@ -229,7 +229,7 @@ impl OverloadedCallType {
fn from_method_id(tcx: &ty::ctxt, method_id: ast::DefId)
-> OverloadedCallType {
let method_descriptor = match ty::impl_or_trait_item(tcx, method_id) {
let method_descriptor = match tcx.impl_or_trait_item(method_id) {
ty::MethodTraitItem(ref method_descriptor) => {
(*method_descriptor).clone()
}
@ -244,7 +244,7 @@ impl OverloadedCallType {
}
ty::ImplContainer(impl_id) => impl_id,
};
let trait_ref = match ty::impl_trait_ref(tcx, impl_id) {
let trait_ref = match tcx.impl_trait_ref(impl_id) {
None => {
tcx.sess.bug("statically resolved overloaded call impl \
didn't implement a trait?!")
@ -502,9 +502,10 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
// make sure that the thing we are pointing out stays valid
// for the lifetime `scope_r` of the resulting ptr:
let expr_ty = return_if_err!(self.typer.node_ty(expr.id));
let r = ty::ty_region(self.tcx(), expr.span, expr_ty);
let bk = ty::BorrowKind::from_mutbl(m);
self.borrow_expr(&**base, r, bk, AddrOf);
if let ty::TyRef(&r, _) = expr_ty.sty {
let bk = ty::BorrowKind::from_mutbl(m);
self.borrow_expr(&**base, r, bk, AddrOf);
}
}
ast::ExprInlineAsm(ref ia) => {
@ -740,7 +741,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
// expression that will actually be used
let with_fields = match with_cmt.ty.sty {
ty::TyStruct(did, substs) => {
ty::struct_fields(self.tcx(), did, substs)
self.tcx().struct_fields(did, substs)
}
_ => {
// the base expression should always evaluate to a
@ -822,7 +823,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
// the method call infrastructure should have
// replaced all late-bound regions with variables:
let self_ty = method_ty.fn_sig().input(0);
let self_ty = ty::no_late_bound_regions(self.tcx(), &self_ty).unwrap();
let self_ty = self.tcx().no_late_bound_regions(&self_ty).unwrap();
let (m, r) = match self_ty.sty {
ty::TyRef(r, ref m) => (m.mutbl, r),
@ -922,10 +923,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
// This is always an rvalue, since we are producing a new
// (temporary) indirection.
let adj_ty =
ty::adjust_ty_for_autoref(self.tcx(),
cmt_base_ty,
opt_autoref);
let adj_ty = cmt_base_ty.adjust_for_autoref(self.tcx(), opt_autoref);
self.mc.cat_rvalue_node(expr.id, expr.span, adj_ty)
}
@ -1074,12 +1072,11 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
// It is also a borrow or copy/move of the value being matched.
match pat.node {
ast::PatIdent(ast::BindByRef(m), _, _) => {
let (r, bk) = {
(ty::ty_region(tcx, pat.span, pat_ty),
ty::BorrowKind::from_mutbl(m))
};
delegate.borrow(pat.id, pat.span, cmt_pat,
r, bk, RefBinding);
if let ty::TyRef(&r, _) = pat_ty.sty {
let bk = ty::BorrowKind::from_mutbl(m);
delegate.borrow(pat.id, pat.span, cmt_pat,
r, bk, RefBinding);
}
}
ast::PatIdent(ast::BindByValue(_), _, _) => {
let mode = copy_or_move(typer, &cmt_pat, PatBindingMove);
@ -1152,7 +1149,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
Some(def::DefVariant(enum_did, variant_did, _is_struct)) => {
let downcast_cmt =
if ty::enum_is_univariant(tcx, enum_did) {
if tcx.enum_is_univariant(enum_did) {
cmt_pat
} else {
let cmt_pat_ty = cmt_pat.ty;
@ -1238,7 +1235,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
fn walk_captures(&mut self, closure_expr: &ast::Expr) {
debug!("walk_captures({:?})", closure_expr);
ty::with_freevars(self.tcx(), closure_expr.id, |freevars| {
self.tcx().with_freevars(closure_expr.id, |freevars| {
for freevar in freevars {
let id_var = freevar.def.def_id().node;
let upvar_id = ty::UpvarId { var_id: id_var,
@ -1283,7 +1280,7 @@ fn copy_or_move<'tcx>(typer: &mc::Typer<'tcx>,
move_reason: MoveReason)
-> ConsumeMode
{
if typer.type_moves_by_default(cmt.span, cmt.ty) {
if typer.type_moves_by_default(cmt.ty, cmt.span) {
Move(move_reason)
} else {
Copy

View file

@ -112,7 +112,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
ty::TyEnum(def_id, substs) |
ty::TyStruct(def_id, substs) => {
let item_scheme = ty::lookup_item_type(self.tcx(), def_id);
let item_scheme = self.tcx().lookup_item_type(def_id);
self.accumulate_from_adt(ty, def_id, &item_scheme.generics, substs)
}
@ -236,7 +236,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
substs: &Substs<'tcx>)
{
let predicates =
ty::lookup_predicates(self.tcx(), def_id).instantiate(self.tcx(), substs);
self.tcx().lookup_predicates(def_id).instantiate(self.tcx(), substs);
let predicates = match self.fully_normalize(&predicates) {
Ok(predicates) => predicates,
Err(ErrorReported) => { return; }
@ -250,7 +250,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
ty::Predicate::Equate(..) => { }
ty::Predicate::Projection(..) => { }
ty::Predicate::RegionOutlives(ref data) => {
match ty::no_late_bound_regions(self.tcx(), data) {
match self.tcx().no_late_bound_regions(data) {
None => { }
Some(ty::OutlivesPredicate(r_a, r_b)) => {
self.push_sub_region_constraint(Some(ty), r_b, r_a);
@ -258,7 +258,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
}
}
ty::Predicate::TypeOutlives(ref data) => {
match ty::no_late_bound_regions(self.tcx(), data) {
match self.tcx().no_late_bound_regions(data) {
None => { }
Some(ty::OutlivesPredicate(ty_a, r_b)) => {
self.stack.push((r_b, Some(ty)));
@ -275,7 +275,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
.map(|pred| Implication::Predicate(def_id, pred));
self.out.extend(obligations);
let variances = ty::item_variances(self.tcx(), def_id);
let variances = self.tcx().item_variances(def_id);
for (&region, &variance) in substs.regions().iter().zip(&variances.regions) {
match variance {
@ -316,7 +316,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
data);
for poly_trait_ref in traits::supertraits(self.tcx(), data.to_poly_trait_ref()) {
match ty::no_late_bound_regions(self.tcx(), &poly_trait_ref) {
match self.tcx().no_late_bound_regions(&poly_trait_ref) {
Some(trait_ref) => { self.accumulate_from_assoc_types(trait_ref); }
None => { }
}
@ -330,7 +330,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
trait_ref);
let trait_def_id = trait_ref.def_id;
let trait_def = ty::lookup_trait_def(self.tcx(), trait_def_id);
let trait_def = self.tcx().lookup_trait_def(trait_def_id);
let assoc_type_projections: Vec<_> =
trait_def.associated_type_names
.iter()
@ -447,5 +447,5 @@ pub fn object_region_bounds<'tcx>(
let mut predicates = others.to_predicates(tcx, open_ty);
predicates.extend(trait_refs.iter().map(|t| t.to_predicate()));
ty::required_region_bounds(tcx, open_ty, predicates)
tcx.required_region_bounds(open_ty, predicates)
}

View file

@ -109,8 +109,8 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Bivariate<'a, 'tcx> {
-> RelateResult<'tcx, ty::Binder<T>>
where T: Relate<'a,'tcx>
{
let a1 = ty::erase_late_bound_regions(self.tcx(), a);
let b1 = ty::erase_late_bound_regions(self.tcx(), b);
let a1 = self.tcx().erase_late_bound_regions(a);
let b1 = self.tcx().erase_late_bound_regions(b);
let c = try!(self.relate(&a1, &b1));
Ok(ty::Binder(c))
}

View file

@ -91,123 +91,125 @@ use syntax::parse::token;
use syntax::print::pprust;
use syntax::ptr::P;
pub fn note_and_explain_region(tcx: &ty::ctxt,
prefix: &str,
region: ty::Region,
suffix: &str) {
fn item_scope_tag(item: &ast::Item) -> &'static str {
match item.node {
ast::ItemImpl(..) => "impl",
ast::ItemStruct(..) => "struct",
ast::ItemEnum(..) => "enum",
ast::ItemTrait(..) => "trait",
ast::ItemFn(..) => "function body",
_ => "item"
}
}
fn explain_span(tcx: &ty::ctxt, heading: &str, span: Span)
-> (String, Option<Span>) {
let lo = tcx.sess.codemap().lookup_char_pos_adj(span.lo);
(format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize()),
Some(span))
}
let (description, span) = match region {
ty::ReScope(scope) => {
let new_string;
let unknown_scope = || {
format!("{}unknown scope: {:?}{}. Please report a bug.",
prefix, scope, suffix)
};
let span = match scope.span(&tcx.map) {
Some(s) => s,
None => return tcx.sess.note(&unknown_scope())
};
let tag = match tcx.map.find(scope.node_id()) {
Some(ast_map::NodeBlock(_)) => "block",
Some(ast_map::NodeExpr(expr)) => match expr.node {
ast::ExprCall(..) => "call",
ast::ExprMethodCall(..) => "method call",
ast::ExprMatch(_, _, ast::MatchSource::IfLetDesugar { .. }) => "if let",
ast::ExprMatch(_, _, ast::MatchSource::WhileLetDesugar) => "while let",
ast::ExprMatch(_, _, ast::MatchSource::ForLoopDesugar) => "for",
ast::ExprMatch(..) => "match",
_ => "expression",
},
Some(ast_map::NodeStmt(_)) => "statement",
Some(ast_map::NodeItem(it)) => item_scope_tag(&*it),
Some(_) | None => {
return tcx.sess.span_note(span, &unknown_scope());
}
};
let scope_decorated_tag = match scope {
region::CodeExtent::Misc(_) => tag,
region::CodeExtent::ParameterScope { .. } => {
"scope of parameters for function"
}
region::CodeExtent::DestructionScope(_) => {
new_string = format!("destruction scope surrounding {}", tag);
&new_string[..]
}
region::CodeExtent::Remainder(r) => {
new_string = format!("block suffix following statement {}",
r.first_statement_index);
&new_string[..]
}
};
explain_span(tcx, scope_decorated_tag, span)
}
ty::ReFree(ref fr) => {
let prefix = match fr.bound_region {
ty::BrAnon(idx) => {
format!("the anonymous lifetime #{} defined on", idx + 1)
}
ty::BrFresh(_) => "an anonymous lifetime defined on".to_owned(),
_ => {
format!("the lifetime {} as defined on",
fr.bound_region)
}
};
match tcx.map.find(fr.scope.node_id) {
Some(ast_map::NodeBlock(ref blk)) => {
let (msg, opt_span) = explain_span(tcx, "block", blk.span);
(format!("{} {}", prefix, msg), opt_span)
}
Some(ast_map::NodeItem(it)) => {
let tag = item_scope_tag(&*it);
let (msg, opt_span) = explain_span(tcx, tag, it.span);
(format!("{} {}", prefix, msg), opt_span)
}
Some(_) | None => {
// this really should not happen
(format!("{} unknown free region bounded by scope {:?}",
prefix, fr.scope), None)
}
impl<'tcx> ty::ctxt<'tcx> {
pub fn note_and_explain_region(&self,
prefix: &str,
region: ty::Region,
suffix: &str) {
fn item_scope_tag(item: &ast::Item) -> &'static str {
match item.node {
ast::ItemImpl(..) => "impl",
ast::ItemStruct(..) => "struct",
ast::ItemEnum(..) => "enum",
ast::ItemTrait(..) => "trait",
ast::ItemFn(..) => "function body",
_ => "item"
}
}
ty::ReStatic => ("the static lifetime".to_owned(), None),
ty::ReEmpty => ("the empty lifetime".to_owned(), None),
ty::ReEarlyBound(ref data) => {
(format!("{}", token::get_name(data.name)), None)
fn explain_span(tcx: &ty::ctxt, heading: &str, span: Span)
-> (String, Option<Span>) {
let lo = tcx.sess.codemap().lookup_char_pos_adj(span.lo);
(format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize()),
Some(span))
}
// I believe these cases should not occur (except when debugging,
// perhaps)
ty::ReInfer(_) | ty::ReLateBound(..) => {
(format!("lifetime {:?}", region), None)
let (description, span) = match region {
ty::ReScope(scope) => {
let new_string;
let unknown_scope = || {
format!("{}unknown scope: {:?}{}. Please report a bug.",
prefix, scope, suffix)
};
let span = match scope.span(&self.map) {
Some(s) => s,
None => return self.sess.note(&unknown_scope())
};
let tag = match self.map.find(scope.node_id()) {
Some(ast_map::NodeBlock(_)) => "block",
Some(ast_map::NodeExpr(expr)) => match expr.node {
ast::ExprCall(..) => "call",
ast::ExprMethodCall(..) => "method call",
ast::ExprMatch(_, _, ast::MatchSource::IfLetDesugar { .. }) => "if let",
ast::ExprMatch(_, _, ast::MatchSource::WhileLetDesugar) => "while let",
ast::ExprMatch(_, _, ast::MatchSource::ForLoopDesugar) => "for",
ast::ExprMatch(..) => "match",
_ => "expression",
},
Some(ast_map::NodeStmt(_)) => "statement",
Some(ast_map::NodeItem(it)) => item_scope_tag(&*it),
Some(_) | None => {
return self.sess.span_note(span, &unknown_scope());
}
};
let scope_decorated_tag = match scope {
region::CodeExtent::Misc(_) => tag,
region::CodeExtent::ParameterScope { .. } => {
"scope of parameters for function"
}
region::CodeExtent::DestructionScope(_) => {
new_string = format!("destruction scope surrounding {}", tag);
&new_string[..]
}
region::CodeExtent::Remainder(r) => {
new_string = format!("block suffix following statement {}",
r.first_statement_index);
&new_string[..]
}
};
explain_span(self, scope_decorated_tag, span)
}
ty::ReFree(ref fr) => {
let prefix = match fr.bound_region {
ty::BrAnon(idx) => {
format!("the anonymous lifetime #{} defined on", idx + 1)
}
ty::BrFresh(_) => "an anonymous lifetime defined on".to_owned(),
_ => {
format!("the lifetime {} as defined on",
fr.bound_region)
}
};
match self.map.find(fr.scope.node_id) {
Some(ast_map::NodeBlock(ref blk)) => {
let (msg, opt_span) = explain_span(self, "block", blk.span);
(format!("{} {}", prefix, msg), opt_span)
}
Some(ast_map::NodeItem(it)) => {
let tag = item_scope_tag(&*it);
let (msg, opt_span) = explain_span(self, tag, it.span);
(format!("{} {}", prefix, msg), opt_span)
}
Some(_) | None => {
// this really should not happen
(format!("{} unknown free region bounded by scope {:?}",
prefix, fr.scope), None)
}
}
}
ty::ReStatic => ("the static lifetime".to_owned(), None),
ty::ReEmpty => ("the empty lifetime".to_owned(), None),
ty::ReEarlyBound(ref data) => {
(format!("{}", token::get_name(data.name)), None)
}
// I believe these cases should not occur (except when debugging,
// perhaps)
ty::ReInfer(_) | ty::ReLateBound(..) => {
(format!("lifetime {:?}", region), None)
}
};
let message = format!("{}{}{}", prefix, description, suffix);
if let Some(span) = span {
self.sess.span_note(span, &message);
} else {
self.sess.note(&message);
}
};
let message = format!("{}{}{}", prefix, description, suffix);
if let Some(span) = span {
tcx.sess.span_note(span, &message);
} else {
tcx.sess.note(&message);
}
}
@ -491,7 +493,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
terr: &ty::type_err<'tcx>) {
let span = trace.origin.span();
self.report_type_error(trace, terr);
ty::note_and_explain_type_err(self.tcx, terr, span);
self.tcx.note_and_explain_type_err(terr, span);
}
/// Returns a string of the form "expected `{}`, found `{}`", or None if this is a derived
@ -576,8 +578,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
&format!(
"consider adding an explicit lifetime bound for `{}`",
bound_kind));
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
&format!("{} must be valid for ", labeled_user_string),
sub,
"...");
@ -600,13 +601,11 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
span_err!(self.tcx.sess, span, E0312,
"lifetime of reference outlines \
lifetime of borrowed content...");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"...the reference is valid for ",
sub,
"...");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"...but the borrowed content is only valid for ",
sup,
"");
@ -615,33 +614,25 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
span_err!(self.tcx.sess, span, E0313,
"lifetime of borrowed pointer outlives \
lifetime of captured variable `{}`...",
ty::local_var_name_str(self.tcx,
upvar_id.var_id)
.to_string());
note_and_explain_region(
self.tcx,
self.tcx.local_var_name_str(upvar_id.var_id));
self.tcx.note_and_explain_region(
"...the borrowed pointer is valid for ",
sub,
"...");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
&format!("...but `{}` is only valid for ",
ty::local_var_name_str(self.tcx,
upvar_id.var_id)
.to_string()),
self.tcx.local_var_name_str(upvar_id.var_id)),
sup,
"");
}
infer::InfStackClosure(span) => {
span_err!(self.tcx.sess, span, E0314,
"closure outlives stack frame");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"...the closure must be valid for ",
sub,
"...");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"...but the closure's stack frame is only valid for ",
sup,
"");
@ -649,8 +640,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
infer::InvokeClosure(span) => {
span_err!(self.tcx.sess, span, E0315,
"cannot invoke closure outside of its lifetime");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"the closure is only valid for ",
sup,
"");
@ -659,8 +649,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
self.tcx.sess.span_err(
span,
"dereference of reference outside its lifetime");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"the reference is only valid for ",
sup,
"");
@ -669,16 +658,13 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
self.tcx.sess.span_err(
span,
&format!("captured variable `{}` does not \
outlive the enclosing closure",
ty::local_var_name_str(self.tcx,
id).to_string()));
note_and_explain_region(
self.tcx,
outlive the enclosing closure",
self.tcx.local_var_name_str(id)));
self.tcx.note_and_explain_region(
"captured variable is valid for ",
sup,
"");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"closure is valid for ",
sub,
"");
@ -686,8 +672,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
infer::IndexSlice(span) => {
self.tcx.sess.span_err(span,
"index of slice outside its lifetime");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"the slice is only valid for ",
sup,
"");
@ -697,13 +682,11 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
span,
"lifetime of the source pointer does not outlive \
lifetime bound of the object type");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"object type is valid for ",
sub,
"");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"source pointer is only valid for ",
sup,
"");
@ -714,7 +697,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
&format!("the type `{}` does not fulfill the \
required lifetime",
self.ty_to_string(ty)));
note_and_explain_region(self.tcx,
self.tcx.note_and_explain_region(
"type must outlive ",
sub,
"");
@ -723,13 +706,11 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
self.tcx.sess.span_err(
span,
"lifetime bound not satisfied");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"lifetime parameter instantiated with ",
sup,
"");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"but lifetime parameter must outlive ",
sub,
"");
@ -740,7 +721,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
&format!("the type `{}` (provided as the value of \
a type parameter) is not valid at this point",
self.ty_to_string(ty)));
note_and_explain_region(self.tcx,
self.tcx.note_and_explain_region(
"type must outlive ",
sub,
"");
@ -750,8 +731,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
span,
"lifetime of method receiver does not outlive \
the method call");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"the receiver is only valid for ",
sup,
"");
@ -761,8 +741,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
span,
"lifetime of function argument does not outlive \
the function call");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"the function argument is only valid for ",
sup,
"");
@ -772,8 +751,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
span,
"lifetime of return value does not outlive \
the function call");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"the return value is only valid for ",
sup,
"");
@ -783,8 +761,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
span,
"lifetime of operand does not outlive \
the operation");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"the operand is only valid for ",
sup,
"");
@ -794,8 +771,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
span,
"reference is not valid \
at the time of borrow");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"the borrow is only valid for ",
sup,
"");
@ -805,8 +781,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
span,
"automatically reference is not valid \
at the time of borrow");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"the automatic borrow is only valid for ",
sup,
"");
@ -817,8 +792,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
&format!("type of expression contains references \
that are not valid during the expression: `{}`",
self.ty_to_string(t)));
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"type is only valid for ",
sup,
"");
@ -829,13 +803,11 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
"unsafe use of destructor: destructor might be called \
while references are dead");
// FIXME (22171): terms "super/subregion" are suboptimal
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"superregion: ",
sup,
"");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"subregion: ",
sub,
"");
@ -844,8 +816,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
self.tcx.sess.span_err(
span,
"lifetime of variable does not enclose its declaration");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"the variable is only valid for ",
sup,
"");
@ -856,13 +827,11 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
&format!("in type `{}`, reference has a longer lifetime \
than the data it references",
self.ty_to_string(ty)));
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"the pointer is valid for ",
sub,
"");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"but the referenced data is only valid for ",
sup,
"");
@ -878,16 +847,14 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
sup_region: Region) {
self.report_inference_failure(var_origin);
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"first, the lifetime cannot outlive ",
sup_region,
"...");
self.note_region_origin(&sup_origin);
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"but, the lifetime must be valid for ",
sub_region,
"...");
@ -903,16 +870,14 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
region2: Region) {
self.report_inference_failure(var_origin);
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"first, the lifetime must be contained by ",
region1,
"...");
self.note_region_origin(&origin1);
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"but, the lifetime must also be contained by ",
region2,
"...");
@ -1353,7 +1318,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
};
match a_def {
def::DefTy(did, _) | def::DefStruct(did) => {
let generics = ty::lookup_item_type(self.tcx, did).generics;
let generics = self.tcx.lookup_item_type(did).generics;
let expected =
generics.regions.len(subst::TypeSpace) as u32;
@ -1591,7 +1556,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
}
infer::UpvarRegion(ref upvar_id, _) => {
format!(" for capture of `{}` by closure",
ty::local_var_name_str(self.tcx, upvar_id.var_id).to_string())
self.tcx.local_var_name_str(upvar_id.var_id).to_string())
}
};
@ -1671,7 +1636,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
span,
&format!(
"...so that closure can access `{}`",
ty::local_var_name_str(self.tcx, upvar_id.var_id)
self.tcx.local_var_name_str(upvar_id.var_id)
.to_string()))
}
infer::InfStackClosure(span) => {
@ -1695,9 +1660,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
span,
&format!("...so that captured variable `{}` \
does not outlive the enclosing closure",
ty::local_var_name_str(
self.tcx,
id).to_string()));
self.tcx.local_var_name_str(id)));
}
infer::IndexSlice(span) => {
self.tcx.sess.span_note(

View file

@ -983,7 +983,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
error_str));
if let Some(err) = err {
ty::note_and_explain_type_err(self.tcx, err, sp)
self.tcx.note_and_explain_type_err(err, sp)
}
}
}

View file

@ -54,7 +54,7 @@ struct IntrinsicCheckingVisitor<'a, 'tcx: 'a> {
impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
fn def_id_is_transmute(&self, def_id: DefId) -> bool {
let intrinsic = match ty::lookup_item_type(self.tcx, def_id).ty.sty {
let intrinsic = match self.tcx.lookup_item_type(def_id).ty.sty {
ty::TyBareFn(_, ref bfty) => bfty.abi == RustIntrinsic,
_ => return false
};
@ -160,8 +160,8 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
// In all cases, we keep the original unsubstituted types
// around for error reporting.
let from_tc = ty::type_contents(self.tcx, from);
let to_tc = ty::type_contents(self.tcx, to);
let from_tc = from.type_contents(self.tcx);
let to_tc = to.type_contents(self.tcx);
if from_tc.interior_param() || to_tc.interior_param() {
span_err!(self.tcx.sess, span, E0139,
"cannot transmute to or from a type that contains \
@ -213,7 +213,7 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
debug!("with_each_combination: space={:?}, index={}, param_ty={:?}",
space, index, param_ty);
if !ty::type_is_sized(Some(param_env), self.tcx, span, param_ty) {
if !param_ty.is_sized(param_env, span) {
debug!("with_each_combination: param_ty is not known to be sized");
substs.types.get_mut_slice(space)[index] = self.dummy_unsized_ty;
@ -253,9 +253,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &ast::Expr) {
if let ast::ExprPath(..) = expr.node {
match ty::resolve_expr(self.tcx, expr) {
match self.tcx.resolve_expr(expr) {
DefFn(did, _) if self.def_id_is_transmute(did) => {
let typ = ty::node_id_to_type(self.tcx, expr.id);
let typ = self.tcx.node_id_to_type(expr.id);
match typ.sty {
TyBareFn(_, ref bare_fn_ty) if bare_fn_ty.abi == RustIntrinsic => {
if let ty::FnConverging(to) = bare_fn_ty.sig.0.output {

View file

@ -465,7 +465,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
// in better error messages than just pointing at the closure
// construction site.
let mut call_caps = Vec::new();
ty::with_freevars(ir.tcx, expr.id, |freevars| {
ir.tcx.with_freevars(expr.id, |freevars| {
for fv in freevars {
if let DefLocal(rv) = fv.def {
let fv_ln = ir.add_live_node(FreeVarNode(fv.span));
@ -1138,7 +1138,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
ast::ExprCall(ref f, ref args) => {
let diverges = !self.ir.tcx.is_method_call(expr.id) &&
ty::expr_ty_adjusted(self.ir.tcx, &**f).fn_ret().diverges();
self.ir.tcx.expr_ty_adjusted(&**f).fn_ret().diverges();
let succ = if diverges {
self.s.exit_ln
} else {
@ -1494,7 +1494,7 @@ fn check_fn(_v: &Liveness,
impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn fn_ret(&self, id: NodeId) -> ty::PolyFnOutput<'tcx> {
let fn_ty = ty::node_id_to_type(self.ir.tcx, id);
let fn_ty = self.ir.tcx.node_id_to_type(id);
match fn_ty.sty {
ty::TyClosure(closure_def_id, substs) =>
self.ir.tcx.closure_type(closure_def_id, substs).sig.output(),
@ -1511,8 +1511,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
{
// within the fn body, late-bound regions are liberated:
let fn_ret =
ty::liberate_late_bound_regions(
self.ir.tcx,
self.ir.tcx.liberate_late_bound_regions(
region::DestructionScopeData::new(body.id),
&self.fn_ret(id));
@ -1527,7 +1526,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
None if !body.stmts.is_empty() =>
match body.stmts.first().unwrap().node {
ast::StmtSemi(ref e, _) => {
ty::expr_ty(self.ir.tcx, &**e) == t_ret
self.ir.tcx.expr_ty(&**e) == t_ret
},
_ => false
},

View file

@ -285,7 +285,7 @@ pub type McResult<T> = Result<T, ()>;
pub trait Typer<'tcx> : ty::ClosureTyper<'tcx> {
fn node_ty(&self, id: ast::NodeId) -> McResult<Ty<'tcx>>;
fn expr_ty_adjusted(&self, expr: &ast::Expr) -> McResult<Ty<'tcx>>;
fn type_moves_by_default(&self, span: Span, ty: Ty<'tcx>) -> bool;
fn type_moves_by_default(&self, ty: Ty<'tcx>, span: Span) -> bool;
fn node_method_ty(&self, method_call: ty::MethodCall) -> Option<Ty<'tcx>>;
fn node_method_origin(&self, method_call: ty::MethodCall)
-> Option<ty::MethodOrigin<'tcx>>;
@ -406,9 +406,10 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
fn expr_ty_adjusted(&self, expr: &ast::Expr) -> McResult<Ty<'tcx>> {
let unadjusted_ty = try!(self.expr_ty(expr));
Ok(ty::adjust_ty(self.tcx(), expr.span, expr.id, unadjusted_ty,
self.typer.adjustments().borrow().get(&expr.id),
|method_call| self.typer.node_method_ty(method_call)))
Ok(unadjusted_ty.adjust(
self.tcx(), expr.span, expr.id,
self.typer.adjustments().borrow().get(&expr.id),
|method_call| self.typer.node_method_ty(method_call)))
}
fn node_ty(&self, id: ast::NodeId) -> McResult<Ty<'tcx>> {
@ -927,8 +928,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
let base_cmt = match method_ty {
Some(method_ty) => {
let ref_ty =
ty::no_late_bound_regions(
self.tcx(), &method_ty.fn_ret()).unwrap().unwrap();
self.tcx().no_late_bound_regions(&method_ty.fn_ret()).unwrap().unwrap();
self.cat_rvalue_node(node.id(), node.span(), ref_ty)
}
None => base_cmt
@ -1024,7 +1024,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
// FIXME(#20649) -- why are we using the `self_ty` as the element type...?
let self_ty = method_ty.fn_sig().input(0);
ty::no_late_bound_regions(self.tcx(), &self_ty).unwrap()
self.tcx().no_late_bound_regions(&self_ty).unwrap()
}
None => {
match base_cmt.ty.builtin_index() {
@ -1244,7 +1244,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
let cmt = match opt_def {
Some(def::DefVariant(enum_did, variant_did, _))
// univariant enums do not need downcasts
if !ty::enum_is_univariant(self.tcx(), enum_did) => {
if !self.tcx().enum_is_univariant(enum_did) => {
self.cat_downcast(pat, cmt.clone(), cmt.ty, variant_did)
}
_ => cmt
@ -1375,7 +1375,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
// types are generated by method resolution and always have
// all late-bound regions fully instantiated, so we just want
// to skip past the binder.
ty::no_late_bound_regions(self.tcx(), &method_ty.fn_ret())
self.tcx().no_late_bound_regions(&method_ty.fn_ret())
.unwrap()
.unwrap() // overloaded ops do not diverge, either
}
@ -1583,7 +1583,7 @@ impl<'tcx> fmt::Debug for categorization<'tcx> {
cat_static_item => write!(f, "static"),
cat_rvalue(r) => write!(f, "rvalue({:?})", r),
cat_local(id) => {
let name = ty::tls::with(|tcx| ty::local_var_name_str(tcx, id));
let name = ty::tls::with(|tcx| tcx.local_var_name_str(id));
write!(f, "local({})", name)
}
cat_upvar(upvar) => {

View file

@ -192,7 +192,7 @@ pub fn simple_identifier<'a>(pat: &'a ast::Pat) -> Option<&'a ast::Ident> {
}
pub fn def_to_path(tcx: &ty::ctxt, id: ast::DefId) -> ast::Path {
ty::with_path(tcx, id, |path| ast::Path {
tcx.with_path(id, |path| ast::Path {
global: false,
segments: path.last().map(|elem| ast::PathSegment {
identifier: ast::Ident::new(elem.name()),

View file

@ -382,7 +382,7 @@ pub fn check_item(tcx: &ty::ctxt, item: &ast::Item, warn_about_defns: bool,
// items.
ast::ItemImpl(_, _, _, Some(ref t), _, ref impl_items) => {
let trait_did = tcx.def_map.borrow().get(&t.ref_id).unwrap().def_id();
let trait_items = ty::trait_items(tcx, trait_did);
let trait_items = tcx.trait_items(trait_did);
for impl_item in impl_items {
let item = trait_items.iter().find(|item| {
@ -425,7 +425,7 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
method_num: index,
..
}) => {
ty::trait_item(tcx, trait_ref.def_id, index).def_id()
tcx.trait_item(trait_ref.def_id, index).def_id()
}
}
}
@ -434,9 +434,9 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
}
ast::ExprField(ref base_e, ref field) => {
span = field.span;
match ty::expr_ty_adjusted(tcx, base_e).sty {
match tcx.expr_ty_adjusted(base_e).sty {
ty::TyStruct(did, _) => {
ty::lookup_struct_fields(tcx, did)
tcx.lookup_struct_fields(did)
.iter()
.find(|f| f.name == field.node.name)
.unwrap_or_else(|| {
@ -451,9 +451,9 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
}
ast::ExprTupField(ref base_e, ref field) => {
span = field.span;
match ty::expr_ty_adjusted(tcx, base_e).sty {
match tcx.expr_ty_adjusted(base_e).sty {
ty::TyStruct(did, _) => {
ty::lookup_struct_fields(tcx, did)
tcx.lookup_struct_fields(did)
.get(field.node)
.unwrap_or_else(|| {
tcx.sess.span_bug(field.span,
@ -468,10 +468,10 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
}
}
ast::ExprStruct(_, ref expr_fields, _) => {
let type_ = ty::expr_ty(tcx, e);
let type_ = tcx.expr_ty(e);
match type_.sty {
ty::TyStruct(did, _) => {
let struct_fields = ty::lookup_struct_fields(tcx, did);
let struct_fields = tcx.lookup_struct_fields(did);
// check the stability of each field that appears
// in the construction expression.
for field in expr_fields {
@ -525,11 +525,11 @@ pub fn check_pat(tcx: &ty::ctxt, pat: &ast::Pat,
debug!("check_pat(pat = {:?})", pat);
if is_internal(tcx, pat.span) { return; }
let did = match ty::pat_ty_opt(tcx, pat) {
let did = match tcx.pat_ty_opt(pat) {
Some(&ty::TyS { sty: ty::TyStruct(did, _), .. }) => did,
Some(_) | None => return,
};
let struct_fields = ty::lookup_struct_fields(tcx, did);
let struct_fields = tcx.lookup_struct_fields(did);
match pat.node {
// Foo(a, b, c)
ast::PatEnum(_, Some(ref pat_fields)) => {
@ -574,7 +574,7 @@ fn is_internal(tcx: &ty::ctxt, span: Span) -> bool {
}
fn is_staged_api(tcx: &ty::ctxt, id: DefId) -> bool {
match ty::trait_item_of_item(tcx, id) {
match tcx.trait_item_of_item(id) {
Some(ty::MethodTraitItemId(trait_method_id))
if trait_method_id != id => {
is_staged_api(tcx, trait_method_id)
@ -602,7 +602,7 @@ fn lookup_uncached<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<&'tcx Stabil
debug!("lookup(id={:?})", id);
// is this definition the implementation of a trait method?
match ty::trait_item_of_item(tcx, id) {
match tcx.trait_item_of_item(id) {
Some(ty::MethodTraitItemId(trait_method_id)) if trait_method_id != id => {
debug!("lookup: trait_method_id={:?}", trait_method_id);
return lookup(tcx, trait_method_id)
@ -617,8 +617,8 @@ fn lookup_uncached<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<&'tcx Stabil
};
item_stab.or_else(|| {
if ty::is_impl(tcx, id) {
if let Some(trait_id) = ty::trait_id_of_impl(tcx, id) {
if tcx.is_impl(id) {
if let Some(trait_id) = tcx.trait_id_of_impl(id) {
// FIXME (#18969): for the time being, simply use the
// stability of the trait to determine the stability of any
// unmarked impls for it. See FIXME above for more details.

View file

@ -38,7 +38,7 @@ pub fn overlapping_impls(infcx: &InferCtxt,
impl1_def_id,
impl2_def_id);
let param_env = &ty::empty_parameter_environment(infcx.tcx);
let param_env = &infcx.tcx.empty_parameter_environment();
let selcx = &mut SelectionContext::intercrate(infcx, param_env);
infcx.probe(|_| {
overlap(selcx, impl1_def_id, impl2_def_id) || overlap(selcx, impl2_def_id, impl1_def_id)
@ -111,7 +111,7 @@ pub fn trait_ref_is_knowable<'tcx>(tcx: &ty::ctxt<'tcx>, trait_ref: &ty::TraitRe
// already
if
trait_ref.def_id.krate != ast::LOCAL_CRATE &&
!ty::has_attr(tcx, trait_ref.def_id, "fundamental")
!tcx.has_attr(trait_ref.def_id, "fundamental")
{
debug!("trait_ref_is_knowable: trait is neither local nor fundamental");
return false;
@ -142,13 +142,13 @@ fn impl_trait_ref_and_oblig<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
let impl_substs =
&substs_fn(selcx.infcx(), DUMMY_SP, impl_def_id);
let impl_trait_ref =
ty::impl_trait_ref(selcx.tcx(), impl_def_id).unwrap();
selcx.tcx().impl_trait_ref(impl_def_id).unwrap();
let impl_trait_ref =
impl_trait_ref.subst(selcx.tcx(), impl_substs);
let Normalized { value: impl_trait_ref, obligations: normalization_obligations1 } =
project::normalize(selcx, ObligationCause::dummy(), &impl_trait_ref);
let predicates = ty::lookup_predicates(selcx.tcx(), impl_def_id);
let predicates = selcx.tcx().lookup_predicates(impl_def_id);
let predicates = predicates.instantiate(selcx.tcx(), impl_substs);
let Normalized { value: predicates, obligations: normalization_obligations2 } =
project::normalize(selcx, ObligationCause::dummy(), &predicates);
@ -183,7 +183,7 @@ pub fn orphan_check<'tcx>(tcx: &ty::ctxt<'tcx>,
// We only except this routine to be invoked on implementations
// of a trait, not inherent implementations.
let trait_ref = ty::impl_trait_ref(tcx, impl_def_id).unwrap();
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
debug!("orphan_check: trait_ref={:?}", trait_ref);
// If the *trait* is local to the crate, ok.
@ -280,9 +280,9 @@ fn fundamental_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool
ty::TyBox(..) | ty::TyRef(..) =>
true,
ty::TyEnum(def_id, _) | ty::TyStruct(def_id, _) =>
ty::has_attr(tcx, def_id, "fundamental"),
tcx.has_attr(def_id, "fundamental"),
ty::TyTrait(ref data) =>
ty::has_attr(tcx, data.principal_def_id(), "fundamental"),
tcx.has_attr(data.principal_def_id(), "fundamental"),
_ =>
false
}

View file

@ -79,14 +79,14 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
span: Span) -> Option<String> {
let def_id = trait_ref.def_id;
let mut report = None;
for item in ty::get_attrs(infcx.tcx, def_id).iter() {
for item in infcx.tcx.get_attrs(def_id).iter() {
if item.check_name("rustc_on_unimplemented") {
let err_sp = if item.meta().span == DUMMY_SP {
span
} else {
item.meta().span
};
let def = ty::lookup_trait_def(infcx.tcx, def_id);
let def = infcx.tcx.lookup_trait_def(def_id);
let trait_str = def.trait_ref.to_string();
if let Some(ref istring) = item.value_str() {
let mut generic_map = def.generics.types.iter_enumerated()
@ -260,7 +260,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
TraitNotObjectSafe(did) => {
span_err!(infcx.tcx.sess, obligation.cause.span, E0038,
"cannot convert to a trait object because trait `{}` is not object-safe",
ty::item_path_str(infcx.tcx, did));
infcx.tcx.item_path_str(did));
for violation in object_safety_violations(infcx.tcx, did) {
match violation {
@ -401,7 +401,7 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>,
match *cause_code {
ObligationCauseCode::MiscObligation => { }
ObligationCauseCode::ItemObligation(item_def_id) => {
let item_name = ty::item_path_str(tcx, item_def_id);
let item_name = tcx.item_path_str(item_def_id);
tcx.sess.span_note(
cause_span,
&format!("required by `{}`", item_name));
@ -442,8 +442,8 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>,
}
ObligationCauseCode::ClosureCapture(var_id, closure_span, builtin_bound) => {
let def_id = tcx.lang_items.from_builtin_kind(builtin_bound).unwrap();
let trait_name = ty::item_path_str(tcx, def_id);
let name = ty::local_var_name_str(tcx, var_id);
let trait_name = tcx.item_path_str(def_id);
let name = tcx.local_var_name_str(var_id);
span_note!(tcx.sess, closure_span,
"the closure that captures `{}` requires that all captured variables \
implement the trait `{}`",

View file

@ -421,7 +421,7 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
// regions. If there are, we will call this obligation an
// error. Eventually we should be able to support some
// cases here, I imagine (e.g., `for<'a> int : 'a`).
if ty::count_late_bound_regions(selcx.tcx(), binder) != 0 {
if selcx.tcx().count_late_bound_regions(binder) != 0 {
errors.push(
FulfillmentError::new(
obligation.clone(),

View file

@ -57,7 +57,7 @@ pub fn is_object_safe<'tcx>(tcx: &ty::ctxt<'tcx>,
-> bool
{
// Because we query yes/no results frequently, we keep a cache:
let def = ty::lookup_trait_def(tcx, trait_def_id);
let def = tcx.lookup_trait_def(trait_def_id);
let result = def.object_safety().unwrap_or_else(|| {
let result = object_safety_violations(tcx, trait_def_id).is_empty();
@ -90,7 +90,7 @@ fn object_safety_violations_for_trait<'tcx>(tcx: &ty::ctxt<'tcx>,
{
// Check methods for violations.
let mut violations: Vec<_> =
ty::trait_items(tcx, trait_def_id).iter()
tcx.trait_items(trait_def_id).iter()
.flat_map(|item| {
match *item {
ty::MethodTraitItem(ref m) => {
@ -122,10 +122,10 @@ fn supertraits_reference_self<'tcx>(tcx: &ty::ctxt<'tcx>,
trait_def_id: ast::DefId)
-> bool
{
let trait_def = ty::lookup_trait_def(tcx, trait_def_id);
let trait_def = tcx.lookup_trait_def(trait_def_id);
let trait_ref = trait_def.trait_ref.clone();
let trait_ref = trait_ref.to_poly_trait_ref();
let predicates = ty::lookup_super_predicates(tcx, trait_def_id);
let predicates = tcx.lookup_super_predicates(trait_def_id);
predicates
.predicates
.into_iter()
@ -153,8 +153,8 @@ fn trait_has_sized_self<'tcx>(tcx: &ty::ctxt<'tcx>,
trait_def_id: ast::DefId)
-> bool
{
let trait_def = ty::lookup_trait_def(tcx, trait_def_id);
let trait_predicates = ty::lookup_predicates(tcx, trait_def_id);
let trait_def = tcx.lookup_trait_def(trait_def_id);
let trait_predicates = tcx.lookup_predicates(trait_def_id);
generics_require_sized_self(tcx, &trait_def.generics, &trait_predicates)
}
@ -169,7 +169,7 @@ fn generics_require_sized_self<'tcx>(tcx: &ty::ctxt<'tcx>,
};
// Search for a predicate like `Self : Sized` amongst the trait bounds.
let free_substs = ty::construct_free_substs(tcx, generics, ast::DUMMY_NODE_ID);
let free_substs = tcx.construct_free_substs(generics, ast::DUMMY_NODE_ID);
let predicates = predicates.instantiate(tcx, &free_substs).predicates.into_vec();
elaborate_predicates(tcx, predicates)
.any(|predicate| {
@ -321,7 +321,7 @@ fn contains_illegal_self_type_reference<'tcx>(tcx: &ty::ctxt<'tcx>,
// Compute supertraits of current trait lazily.
if supertraits.is_none() {
let trait_def = ty::lookup_trait_def(tcx, trait_def_id);
let trait_def = tcx.lookup_trait_def(trait_def_id);
let trait_ref = ty::Binder(trait_def.trait_ref.clone());
supertraits = Some(traits::supertraits(tcx, trait_ref).collect());
}

View file

@ -574,7 +574,7 @@ fn assemble_candidates_from_trait_def<'cx,'tcx>(
};
// If so, extract what we know from the trait and try to come up with a good answer.
let trait_predicates = ty::lookup_predicates(selcx.tcx(), trait_ref.def_id);
let trait_predicates = selcx.tcx().lookup_predicates(trait_ref.def_id);
let bounds = trait_predicates.instantiate(selcx.tcx(), trait_ref.substs);
let bounds = elaborate_predicates(selcx.tcx(), bounds.predicates.into_vec());
assemble_candidates_from_predicates(selcx, obligation, obligation_trait_ref,
@ -892,7 +892,7 @@ fn confirm_impl_candidate<'cx,'tcx>(
// It is not in the impl - get the default from the trait.
let trait_ref = obligation.predicate.trait_ref;
for trait_item in ty::trait_items(selcx.tcx(), trait_ref.def_id).iter() {
for trait_item in selcx.tcx().trait_items(trait_ref.def_id).iter() {
if let &ty::TypeTraitItem(ref assoc_ty) = trait_item {
if assoc_ty.name == obligation.predicate.item_name {
if let Some(ty) = assoc_ty.ty {

View file

@ -773,7 +773,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
match candidate {
ImplCandidate(def_id) => {
match ty::trait_impl_polarity(self.tcx(), def_id) {
match self.tcx().trait_impl_polarity(def_id) {
Some(ast::ImplPolarity::Negative) => return Err(Unimplemented),
_ => {}
}
@ -1024,7 +1024,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
projection_trait_ref={:?}",
projection_trait_ref);
let trait_predicates = ty::lookup_predicates(self.tcx(), projection_trait_ref.def_id);
let trait_predicates = self.tcx().lookup_predicates(projection_trait_ref.def_id);
let bounds = trait_predicates.instantiate(self.tcx(), projection_trait_ref.substs);
debug!("match_projection_obligation_against_bounds_from_trait: \
bounds={:?}",
@ -1224,7 +1224,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
{
debug!("assemble_candidates_from_impls(obligation={:?})", obligation);
let def = ty::lookup_trait_def(self.tcx(), obligation.predicate.def_id());
let def = self.tcx().lookup_trait_def(obligation.predicate.def_id());
def.for_each_relevant_impl(
self.tcx(),
@ -1252,7 +1252,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let def_id = obligation.predicate.def_id();
if ty::trait_has_default_impl(self.tcx(), def_id) {
if self.tcx().trait_has_default_impl(def_id) {
match self_ty.sty {
ty::TyTrait(..) => {
// For object types, we don't know what the closed
@ -1264,7 +1264,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// object types, because it just lets you reflect
// onto the object type, not into the object's
// interior.
if ty::has_attr(self.tcx(), def_id, "rustc_reflect_like") {
if self.tcx().has_attr(def_id, "rustc_reflect_like") {
candidates.vec.push(DefaultImplObjectCandidate(def_id));
}
}
@ -1397,7 +1397,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// T: Trait
// so it seems ok if we (conservatively) fail to accept that `Unsize`
// obligation above. Should be possible to extend this in the future.
let self_ty = match ty::no_late_bound_regions(self.tcx(), &obligation.self_ty()) {
let self_ty = match self.tcx().no_late_bound_regions(&obligation.self_ty()) {
Some(t) => t,
None => {
// Don't add any candidates if there are bound regions.
@ -1736,7 +1736,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ty::TyStruct(def_id, substs) => {
let types: Vec<Ty> =
ty::struct_fields(self.tcx(), def_id, substs).iter()
self.tcx().struct_fields(def_id, substs).iter()
.map(|f| f.mt.ty)
.collect();
nominal(bound, types)
@ -1744,7 +1744,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ty::TyEnum(def_id, substs) => {
let types: Vec<Ty> =
ty::substd_enum_variants(self.tcx(), def_id, substs)
self.tcx().substd_enum_variants(def_id, substs)
.iter()
.flat_map(|variant| &variant.args)
.cloned()
@ -1881,13 +1881,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
ty::TyStruct(def_id, substs) => {
Some(ty::struct_fields(self.tcx(), def_id, substs).iter()
Some(self.tcx().struct_fields(def_id, substs).iter()
.map(|f| f.mt.ty)
.collect())
}
ty::TyEnum(def_id, substs) => {
Some(ty::substd_enum_variants(self.tcx(), def_id, substs)
Some(self.tcx().substd_enum_variants(def_id, substs)
.iter()
.flat_map(|variant| &variant.args)
.map(|&ty| ty)
@ -2161,7 +2161,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
obligation,
trait_def_id);
assert!(ty::has_attr(self.tcx(), trait_def_id, "rustc_reflect_like"));
assert!(self.tcx().has_attr(trait_def_id, "rustc_reflect_like"));
// OK to skip binder, it is reintroduced below
let self_ty = self.infcx.shallow_resolve(obligation.predicate.skip_binder().self_ty());
@ -2178,7 +2178,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// reintroduce the two binding levels we skipped, then flatten into one
let all_types = ty::Binder(ty::Binder(all_types));
let all_types = ty::flatten_late_bound_regions(self.tcx(), &all_types);
let all_types = self.tcx().flatten_late_bound_regions(&all_types);
self.vtable_default_impl(obligation, trait_def_id, all_types)
}
@ -2434,7 +2434,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// assemble_candidates_for_unsizing should ensure there are no late bound
// regions here. See the comment there for more details.
let source = self.infcx.shallow_resolve(
ty::no_late_bound_regions(tcx, &obligation.self_ty()).unwrap());
tcx.no_late_bound_regions(&obligation.self_ty()).unwrap());
let target = self.infcx.shallow_resolve(obligation.predicate.0.input_types()[0]);
debug!("confirm_builtin_unsize_candidate(source={:?}, target={:?})",
@ -2525,8 +2525,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// Struct<T> -> Struct<U>.
(&ty::TyStruct(def_id, substs_a), &ty::TyStruct(_, substs_b)) => {
let fields = ty::lookup_struct_fields(tcx, def_id).iter().map(|f| {
ty::lookup_field_type_unsubstituted(tcx, def_id, f.id)
let fields = tcx.lookup_struct_fields(def_id).iter().map(|f| {
tcx.lookup_field_type_unsubstituted(def_id, f.id)
}).collect::<Vec<_>>();
// The last field of the structure has to exist and contain type parameters.
@ -2628,7 +2628,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
-> Result<(Normalized<'tcx, Substs<'tcx>>,
infer::SkolemizationMap), ()>
{
let impl_trait_ref = ty::impl_trait_ref(self.tcx(), impl_def_id).unwrap();
let impl_trait_ref = self.tcx().impl_trait_ref(impl_def_id).unwrap();
// Before we create the substitutions and everything, first
// consider a "quick reject". This avoids creating more types
@ -2765,7 +2765,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
impl_def_id);
// Find the self type for the impl.
let impl_self_ty = ty::lookup_item_type(self.tcx(), impl_def_id).ty;
let impl_self_ty = self.tcx().lookup_item_type(impl_def_id).ty;
let impl_self_ty = impl_self_ty.subst(self.tcx(), &impl_substs);
debug!("match_impl_self_types(obligation_self_ty={:?}, impl_self_ty={:?})",
@ -2890,7 +2890,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
{
debug!("impl_or_trait_obligations(def_id={:?})", def_id);
let predicates = ty::lookup_predicates(self.tcx(), def_id);
let predicates = self.tcx().lookup_predicates(def_id);
let predicates = predicates.instantiate(self.tcx(), substs);
let predicates = normalize_with_depth(self, cause.clone(), recursion_depth, &predicates);
let mut predicates = self.infcx().plug_leaks(skol_map, snapshot, &predicates);

View file

@ -43,19 +43,19 @@ impl<'a,'tcx> PredicateSet<'a,'tcx> {
// regions before we throw things into the underlying set.
let normalized_pred = match *pred {
ty::Predicate::Trait(ref data) =>
ty::Predicate::Trait(ty::anonymize_late_bound_regions(self.tcx, data)),
ty::Predicate::Trait(self.tcx.anonymize_late_bound_regions(data)),
ty::Predicate::Equate(ref data) =>
ty::Predicate::Equate(ty::anonymize_late_bound_regions(self.tcx, data)),
ty::Predicate::Equate(self.tcx.anonymize_late_bound_regions(data)),
ty::Predicate::RegionOutlives(ref data) =>
ty::Predicate::RegionOutlives(ty::anonymize_late_bound_regions(self.tcx, data)),
ty::Predicate::RegionOutlives(self.tcx.anonymize_late_bound_regions(data)),
ty::Predicate::TypeOutlives(ref data) =>
ty::Predicate::TypeOutlives(ty::anonymize_late_bound_regions(self.tcx, data)),
ty::Predicate::TypeOutlives(self.tcx.anonymize_late_bound_regions(data)),
ty::Predicate::Projection(ref data) =>
ty::Predicate::Projection(ty::anonymize_late_bound_regions(self.tcx, data)),
ty::Predicate::Projection(self.tcx.anonymize_late_bound_regions(data)),
};
self.set.insert(normalized_pred)
}
@ -116,7 +116,7 @@ impl<'cx, 'tcx> Elaborator<'cx, 'tcx> {
match *predicate {
ty::Predicate::Trait(ref data) => {
// Predicates declared on the trait.
let predicates = ty::lookup_super_predicates(self.tcx, data.def_id());
let predicates = self.tcx.lookup_super_predicates(data.def_id());
let mut predicates: Vec<_> =
predicates.predicates
@ -236,7 +236,7 @@ impl<'cx, 'tcx> Iterator for SupertraitDefIds<'cx, 'tcx> {
None => { return None; }
};
let predicates = ty::lookup_super_predicates(self.tcx, def_id);
let predicates = self.tcx.lookup_super_predicates(def_id);
let visited = &mut self.visited;
self.stack.extend(
predicates.predicates
@ -297,7 +297,7 @@ pub fn fresh_type_vars_for_impl<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
-> Substs<'tcx>
{
let tcx = infcx.tcx;
let impl_generics = ty::lookup_item_type(tcx, impl_def_id).generics;
let impl_generics = tcx.lookup_item_type(impl_def_id).generics;
infcx.fresh_substs_for_generics(span, &impl_generics)
}
@ -416,7 +416,7 @@ pub fn get_vtable_index_of_object_method<'tcx>(tcx: &ty::ctxt<'tcx>,
break;
}
let trait_items = ty::trait_items(tcx, bound_ref.def_id());
let trait_items = tcx.trait_items(bound_ref.def_id());
for trait_item in trait_items.iter() {
match *trait_item {
ty::MethodTraitItem(_) => method_count += 1,
@ -427,7 +427,7 @@ pub fn get_vtable_index_of_object_method<'tcx>(tcx: &ty::ctxt<'tcx>,
// count number of methods preceding the one we are selecting and
// add them to the total offset; skip over associated types.
let trait_items = ty::trait_items(tcx, trait_def_id);
let trait_items = tcx.trait_items(trait_def_id);
for trait_item in trait_items.iter().take(method_offset_in_trait) {
match *trait_item {
ty::MethodTraitItem(_) => method_count += 1,

File diff suppressed because it is too large Load diff

View file

@ -113,7 +113,7 @@ fn relate_item_substs<'a,'tcx:'a,R>(relation: &mut R,
let variances;
let opt_variances = if relation.tcx().variance_computed.get() {
variances = ty::item_variances(relation.tcx(), item_def_id);
variances = relation.tcx().item_variances(item_def_id);
Some(&*variances)
} else {
None

View file

@ -71,7 +71,7 @@ fn parameterized<GG>(f: &mut fmt::Formatter,
where GG: for<'tcx> FnOnce(&ty::ctxt<'tcx>) -> ty::Generics<'tcx>
{
let (fn_trait_kind, verbose) = try!(ty::tls::with(|tcx| {
try!(write!(f, "{}", ty::item_path_str(tcx, did)));
try!(write!(f, "{}", tcx.item_path_str(did)));
Ok((tcx.lang_items.fn_trait_kind(did), tcx.sess.verbose()))
}));
@ -265,7 +265,7 @@ impl<'tcx> fmt::Display for TraitAndProjections<'tcx> {
parameterized(f, trait_ref.substs,
trait_ref.def_id,
projection_bounds,
|tcx| ty::lookup_trait_def(tcx, trait_ref.def_id).generics.clone())
|tcx| tcx.lookup_trait_def(trait_ref.def_id).generics.clone())
}
}
@ -616,7 +616,7 @@ impl fmt::Display for ty::Binder<ty::OutlivesPredicate<ty::Region, ty::Region>>
impl<'tcx> fmt::Display for ty::TraitRef<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
parameterized(f, self.substs, self.def_id, &[],
|tcx| ty::lookup_trait_def(tcx, self.def_id).generics.clone())
|tcx| tcx.lookup_trait_def(self.def_id).generics.clone())
}
}
@ -671,7 +671,7 @@ impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> {
if let Some(def_id) = opt_def_id {
try!(write!(f, " {{{}}}", ty::tls::with(|tcx| {
ty::item_path_str(tcx, def_id)
tcx.item_path_str(def_id)
})));
}
Ok(())
@ -681,7 +681,7 @@ impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> {
TyParam(ref param_ty) => write!(f, "{}", param_ty),
TyEnum(did, substs) | TyStruct(did, substs) => {
parameterized(f, substs, did, &[],
|tcx| ty::lookup_item_type(tcx, did).generics)
|tcx| tcx.lookup_item_type(did).generics)
}
TyTrait(ref data) => write!(f, "{}", data),
ty::TyProjection(ref data) => write!(f, "{}", data),
@ -720,7 +720,7 @@ impl fmt::Debug for ty::UpvarId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "UpvarId({};`{}`;{})",
self.var_id,
ty::tls::with(|tcx| ty::local_var_name_str(tcx, self.var_id)),
ty::tls::with(|tcx| tcx.local_var_name_str(self.var_id)),
self.closure_expr_id)
}
}

View file

@ -752,7 +752,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
LpExtend(ref lp_base, _, LpInterior(InteriorField(_))) => {
match lp_base.to_type().sty {
ty::TyStruct(def_id, _) | ty::TyEnum(def_id, _) => {
if ty::has_dtor(self.tcx(), def_id) {
if self.tcx().has_dtor(def_id) {
// In the case where the owner implements drop, then
// the path must be initialized to prevent a case of
// partial reinitialization

View file

@ -353,7 +353,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
}
(&ty::TyStruct(def_id, ref _substs), None) => {
let fields = ty::lookup_struct_fields(tcx, def_id);
let fields = tcx.lookup_struct_fields(def_id);
match *origin_field_name {
mc::NamedField(ast_name) => {
for f in &fields {
@ -378,7 +378,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
(&ty::TyEnum(enum_def_id, substs), ref enum_variant_info) => {
let variant_info = {
let mut variants = ty::substd_enum_variants(tcx, enum_def_id, substs);
let mut variants = tcx.substd_enum_variants(enum_def_id, substs);
match *enum_variant_info {
Some((variant_def_id, ref _lp2)) =>
variants.iter()
@ -442,9 +442,9 @@ fn add_fragment_sibling_core<'tcx>(this: &MoveData<'tcx>,
let loan_path_elem = LpInterior(InteriorField(new_field_name));
let new_lp_type = match new_field_name {
mc::NamedField(ast_name) =>
ty::named_element_ty(tcx, parent.to_type(), ast_name, opt_variant_did),
tcx.named_element_ty(parent.to_type(), ast_name, opt_variant_did),
mc::PositionalField(idx) =>
ty::positional_element_ty(tcx, parent.to_type(), idx, opt_variant_did),
tcx.positional_element_ty(parent.to_type(), idx, opt_variant_did),
};
let new_lp_variant = LpExtend(parent, mc, loan_path_elem);
let new_lp = LoanPath::new(new_lp_variant, new_lp_type.unwrap());

View file

@ -35,7 +35,7 @@ pub fn gather_decl<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
decl_id: ast::NodeId,
_decl_span: Span,
var_id: ast::NodeId) {
let ty = ty::node_id_to_type(bccx.tcx, var_id);
let ty = bccx.tcx.node_id_to_type(var_id);
let loan_path = Rc::new(LoanPath::new(LpVar(var_id), ty));
move_data.add_move(bccx.tcx, loan_path, decl_id, Declared);
}
@ -180,7 +180,7 @@ fn check_and_get_illegal_move_origin<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
mc::cat_interior(ref b, mc::InteriorElement(Kind::Pattern, _)) => {
match b.ty.sty {
ty::TyStruct(did, _) | ty::TyEnum(did, _) => {
if ty::has_dtor(bccx.tcx, did) {
if bccx.tcx.has_dtor(did) {
Some(cmt.clone())
} else {
check_and_get_illegal_move_origin(bccx, b)

View file

@ -490,7 +490,7 @@ struct StaticInitializerCtxt<'a, 'tcx: 'a> {
impl<'a, 'tcx, 'v> Visitor<'v> for StaticInitializerCtxt<'a, 'tcx> {
fn visit_expr(&mut self, ex: &Expr) {
if let ast::ExprAddrOf(mutbl, ref base) = ex.node {
let param_env = ty::empty_parameter_environment(self.bccx.tcx);
let param_env = self.bccx.tcx.empty_parameter_environment();
let mc = mc::MemCategorizationContext::new(&param_env);
let base_cmt = mc.cat_expr(&**base).unwrap();
let borrow_kind = ty::BorrowKind::from_mutbl(mutbl);

View file

@ -137,7 +137,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
mc::cat_interior(ref b, mc::InteriorField(_)) => {
match b.ty.sty {
ty::TyStruct(did, _) |
ty::TyEnum(did, _) if ty::has_dtor(bccx.tcx, did) => {
ty::TyEnum(did, _) if bccx.tcx.has_dtor(did) => {
bccx.span_err(
move_from.span,
&format!("cannot move out of type `{}`, \

View file

@ -29,8 +29,8 @@ use rustc::middle::dataflow::DataFlowOperator;
use rustc::middle::dataflow::KillFrom;
use rustc::middle::expr_use_visitor as euv;
use rustc::middle::free_region::FreeRegionMap;
use rustc::middle::infer::error_reporting::note_and_explain_region;
use rustc::middle::mem_categorization as mc;
use rustc::middle::mem_categorization::Typer;
use rustc::middle::region;
use rustc::middle::ty::{self, Ty};
@ -662,7 +662,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
.map
.find(the_move.id) {
Some(ast_map::NodeExpr(expr)) => {
(ty::expr_ty_adjusted(self.tcx, &*expr), expr.span)
(self.tcx.expr_ty_adjusted(&*expr), expr.span)
}
r => {
self.tcx.sess.bug(&format!("MoveExpr({}) maps to \
@ -696,7 +696,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
}
move_data::MovePat => {
let pat_ty = ty::node_id_to_type(self.tcx, the_move.id);
let pat_ty = self.tcx.node_id_to_type(the_move.id);
let span = self.tcx.map.span(the_move.id);
self.tcx.sess.span_note(span,
&format!("`{}` moved here{} because it has type `{}`, \
@ -713,7 +713,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
.map
.find(the_move.id) {
Some(ast_map::NodeExpr(expr)) => {
(ty::expr_ty_adjusted(self.tcx, &*expr), expr.span)
(self.tcx.expr_ty_adjusted(&*expr), expr.span)
}
r => {
self.tcx.sess.bug(&format!("Captured({}) maps to \
@ -747,7 +747,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
-> (&'static str, &'static str) {
match ty.sty {
_ => {
if ty::type_moves_by_default(param_env, span, ty) {
if param_env.type_moves_by_default(ty, span) {
("non-copyable",
"perhaps you meant to use `clone()`?")
} else {
@ -997,13 +997,11 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
}
err_out_of_scope(super_scope, sub_scope) => {
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"reference must be valid for ",
sub_scope,
"...");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
"...but borrowed value is only valid for ",
super_scope,
"");
@ -1020,14 +1018,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
}
None => self.cmt_to_string(&*err.cmt),
};
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
&format!("{} would have to be valid for ",
descr),
loan_scope,
"...");
note_and_explain_region(
self.tcx,
self.tcx.note_and_explain_region(
&format!("...but {} is only valid for ", descr),
ptr_scope,
"");
@ -1041,14 +1037,14 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
match loan_path.kind {
LpUpvar(ty::UpvarId{ var_id: id, closure_expr_id: _ }) |
LpVar(id) => {
out.push_str(&ty::local_var_name_str(self.tcx, id));
out.push_str(&self.tcx.local_var_name_str(id));
}
LpDowncast(ref lp_base, variant_def_id) => {
out.push('(');
self.append_loan_path_to_string(&**lp_base, out);
out.push_str(DOWNCAST_PRINTED_OPERATOR);
out.push_str(&ty::item_path_str(self.tcx, variant_def_id));
out.push_str(&self.tcx.item_path_str(variant_def_id));
out.push(')');
}
@ -1094,7 +1090,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
out.push('(');
self.append_autoderefd_loan_path_to_string(&**lp_base, out);
out.push(':');
out.push_str(&ty::item_path_str(self.tcx, variant_def_id));
out.push_str(&self.tcx.item_path_str(variant_def_id));
out.push(')');
}
@ -1184,7 +1180,7 @@ impl<'tcx> fmt::Debug for LoanPath<'tcx> {
LpDowncast(ref lp, variant_def_id) => {
let variant_str = if variant_def_id.krate == ast::LOCAL_CRATE {
ty::tls::with(|tcx| ty::item_path_str(tcx, variant_def_id))
ty::tls::with(|tcx| tcx.item_path_str(variant_def_id))
} else {
format!("{:?}", variant_def_id)
};
@ -1216,7 +1212,7 @@ impl<'tcx> fmt::Display for LoanPath<'tcx> {
LpDowncast(ref lp, variant_def_id) => {
let variant_str = if variant_def_id.krate == ast::LOCAL_CRATE {
ty::tls::with(|tcx| ty::item_path_str(tcx, variant_def_id))
ty::tls::with(|tcx| tcx.item_path_str(variant_def_id))
} else {
format!("{:?}", variant_def_id)
};

View file

@ -648,16 +648,16 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: Session,
time(time_passes, "static item recursion checking", (), |_|
middle::check_static_recursion::check_crate(&sess, krate, &def_map, &ast_map));
ty::with_ctxt(sess,
arenas,
def_map,
named_region_map,
ast_map,
freevars,
region_map,
lang_items,
stability::Index::new(krate),
|tcx| {
ty::ctxt::create_and_enter(sess,
arenas,
def_map,
named_region_map,
ast_map,
freevars,
region_map,
lang_items,
stability::Index::new(krate),
|tcx| {
// passes are timed inside typeck
typeck::check_crate(tcx, trait_map);

View file

@ -317,7 +317,7 @@ impl<'a, 'tcx> pprust::PpAnn for TypedAnnotation<'a, 'tcx> {
try!(pp::word(&mut s.s, "as"));
try!(pp::space(&mut s.s));
try!(pp::word(&mut s.s,
&ty::expr_ty(self.tcx, expr).to_string()));
&self.tcx.expr_ty(expr).to_string()));
s.pclose()
}
_ => Ok(())

View file

@ -130,16 +130,16 @@ fn test_env<F>(source_string: &str,
resolve::resolve_crate(&sess, &ast_map, resolve::MakeGlobMap::No);
let named_region_map = resolve_lifetime::krate(&sess, krate, &def_map);
let region_map = region::resolve_crate(&sess, krate);
ty::with_ctxt(sess,
&arenas,
def_map,
named_region_map,
ast_map,
freevars,
region_map,
lang_items,
stability::Index::new(krate),
|tcx| {
ty::ctxt::create_and_enter(sess,
&arenas,
def_map,
named_region_map,
ast_map,
freevars,
region_map,
lang_items,
stability::Index::new(krate),
|tcx| {
let infcx = infer::new_infer_ctxt(tcx);
body(Env { infcx: &infcx });
let free_regions = FreeRegionMap::new();

View file

@ -30,6 +30,7 @@
use metadata::{csearch, decoder};
use middle::def::*;
use middle::mem_categorization::Typer;
use middle::subst::Substs;
use middle::ty::{self, Ty};
use middle::{def, pat_util, stability};
@ -142,7 +143,7 @@ impl LintPass for TypeLimits {
}
},
_ => {
let t = ty::expr_ty(cx.tcx, &**expr);
let t = cx.tcx.expr_ty(&**expr);
match t.sty {
ty::TyUint(_) => {
cx.span_lint(UNSIGNED_NEGATION, e.span,
@ -168,7 +169,7 @@ impl LintPass for TypeLimits {
}
if is_shift_binop(binop.node) {
let opt_ty_bits = match ty::expr_ty(cx.tcx, &**l).sty {
let opt_ty_bits = match cx.tcx.expr_ty(&**l).sty {
ty::TyInt(t) => Some(int_ty_bits(t, cx.sess().target.int_type)),
ty::TyUint(t) => Some(uint_ty_bits(t, cx.sess().target.uint_type)),
_ => None
@ -193,7 +194,7 @@ impl LintPass for TypeLimits {
}
},
ast::ExprLit(ref lit) => {
match ty::expr_ty(cx.tcx, e).sty {
match cx.tcx.expr_ty(e).sty {
ty::TyInt(t) => {
match lit.node {
ast::LitInt(v, ast::SignedIntLit(_, ast::Plus)) |
@ -343,7 +344,7 @@ impl LintPass for TypeLimits {
} else {
binop
};
match ty::expr_ty(tcx, expr).sty {
match tcx.expr_ty(expr).sty {
ty::TyInt(int_ty) => {
let (min, max) = int_ty_range(int_ty);
let lit_val: i64 = match lit.node {
@ -412,7 +413,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
None => panic!("ast_ty_to_ty_cache was incomplete after typeck!")
};
if !ty::is_ffi_safe(self.cx.tcx, tty) {
if !tty.is_ffi_safe(self.cx.tcx) {
self.cx.span_lint(IMPROPER_CTYPES, sp,
"found type without foreign-function-safe \
representation annotation in foreign module, consider \
@ -482,20 +483,11 @@ pub struct BoxPointers;
impl BoxPointers {
fn check_heap_type<'a, 'tcx>(&self, cx: &Context<'a, 'tcx>,
span: Span, ty: Ty<'tcx>) {
let mut n_uniq: usize = 0;
ty::fold_ty(cx.tcx, ty, |t| {
match t.sty {
ty::TyBox(_) => {
n_uniq += 1;
}
_ => ()
};
t
});
if n_uniq > 0 {
let m = format!("type uses owned (Box type) pointers: {}", ty);
cx.span_lint(BOX_POINTERS, span, &m[..]);
for leaf_ty in ty.walk() {
if let ty::TyBox(_) = leaf_ty.sty {
let m = format!("type uses owned (Box type) pointers: {}", ty);
cx.span_lint(BOX_POINTERS, span, &m);
}
}
}
}
@ -512,7 +504,7 @@ impl LintPass for BoxPointers {
ast::ItemEnum(..) |
ast::ItemStruct(..) =>
self.check_heap_type(cx, it.span,
ty::node_id_to_type(cx.tcx, it.id)),
cx.tcx.node_id_to_type(it.id)),
_ => ()
}
@ -521,7 +513,7 @@ impl LintPass for BoxPointers {
ast::ItemStruct(ref struct_def, _) => {
for struct_field in &struct_def.fields {
self.check_heap_type(cx, struct_field.span,
ty::node_id_to_type(cx.tcx, struct_field.node.id));
cx.tcx.node_id_to_type(struct_field.node.id));
}
}
_ => ()
@ -529,7 +521,7 @@ impl LintPass for BoxPointers {
}
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
let ty = ty::expr_ty(cx.tcx, e);
let ty = cx.tcx.expr_ty(e);
self.check_heap_type(cx, e.span, ty);
}
}
@ -582,13 +574,13 @@ impl LintPass for RawPointerDerive {
ast::ItemImpl(_, _, _, ref t_ref_opt, _, _) => {
// Deriving the Copy trait does not cause a warning
if let &Some(ref trait_ref) = t_ref_opt {
let def_id = ty::trait_ref_to_def_id(cx.tcx, trait_ref);
let def_id = cx.tcx.trait_ref_to_def_id(trait_ref);
if Some(def_id) == cx.tcx.lang_items.copy_trait() {
return;
}
}
match ty::node_id_to_type(cx.tcx, item.id).sty {
match cx.tcx.node_id_to_type(item.id).sty {
ty::TyEnum(did, _) => did,
ty::TyStruct(did, _) => did,
_ => return,
@ -732,7 +724,7 @@ impl LintPass for UnusedResults {
return;
}
let t = ty::expr_ty(cx.tcx, expr);
let t = cx.tcx.expr_ty(expr);
let warned = match t.sty {
ty::TyTuple(ref tys) if tys.is_empty() => return,
ty::TyBool => return,
@ -877,7 +869,7 @@ fn method_context(cx: &Context, id: ast::NodeId, span: Span) -> MethodContext {
Some(item) => match item.container() {
ty::TraitContainer(..) => MethodContext::TraitDefaultImpl,
ty::ImplContainer(cid) => {
match ty::impl_trait_ref(cx.tcx, cid) {
match cx.tcx.impl_trait_ref(cid) {
Some(_) => MethodContext::TraitImpl,
None => MethodContext::PlainImpl
}
@ -1601,7 +1593,7 @@ impl LintPass for MissingDoc {
ast::ItemImpl(_, _, _, Some(ref trait_ref), _, ref impl_items) => {
// If the trait is private, add the impl items to private_traits so they don't get
// reported for missing docs.
let real_trait = ty::trait_ref_to_def_id(cx.tcx, trait_ref);
let real_trait = cx.tcx.trait_ref_to_def_id(trait_ref);
match cx.tcx.map.find(real_trait.node) {
Some(ast_map::NodeItem(item)) => if item.vis == ast::Visibility::Inherited {
for itm in impl_items {
@ -1711,11 +1703,11 @@ impl LintPass for MissingCopyImplementations {
}
_ => return,
};
let parameter_environment = ty::empty_parameter_environment(cx.tcx);
if !ty::type_moves_by_default(&parameter_environment, item.span, ty) {
let parameter_environment = cx.tcx.empty_parameter_environment();
if !parameter_environment.type_moves_by_default(ty, item.span) {
return;
}
if ty::can_type_implement_copy(&parameter_environment, item.span, ty).is_ok() {
if parameter_environment.can_type_implement_copy(ty, item.span).is_ok() {
cx.span_lint(MISSING_COPY_IMPLEMENTATIONS,
item.span,
"type could implement `Copy`; consider adding `impl \
@ -1763,11 +1755,11 @@ impl LintPass for MissingDebugImplementations {
};
if self.impling_types.is_none() {
let debug_def = ty::lookup_trait_def(cx.tcx, debug);
let debug_def = cx.tcx.lookup_trait_def(debug);
let mut impls = NodeSet();
debug_def.for_each_impl(cx.tcx, |d| {
if d.krate == ast::LOCAL_CRATE {
if let Some(ty_def) = ty::ty_to_def_id(ty::node_id_to_type(cx.tcx, d.node)) {
if let Some(ty_def) = cx.tcx.node_id_to_type(d.node).ty_to_def_id() {
impls.insert(ty_def.node);
}
}
@ -1878,7 +1870,7 @@ impl LintPass for UnconditionalRecursion {
visit::FkFnBlock => return
};
let impl_def_id = ty::impl_of_method(cx.tcx, local_def(id))
let impl_def_id = cx.tcx.impl_of_method(local_def(id))
.unwrap_or(local_def(ast::DUMMY_NODE_ID));
assert!(ast_util::is_local(impl_def_id));
let impl_node_id = impl_def_id.node;
@ -2010,7 +2002,7 @@ impl LintPass for UnconditionalRecursion {
// method instead.
ty::MethodTypeParam(
ty::MethodParam { ref trait_ref, method_num, impl_def_id: None, }) => {
ty::trait_item(tcx, trait_ref.def_id, method_num).def_id()
tcx.trait_item(trait_ref.def_id, method_num).def_id()
}
// The `impl` is known, so we check that with a
@ -2175,11 +2167,11 @@ impl LintPass for MutableTransmutes {
ast::ExprPath(..) => (),
_ => return None
}
if let DefFn(did, _) = ty::resolve_expr(cx.tcx, expr) {
if let DefFn(did, _) = cx.tcx.resolve_expr(expr) {
if !def_id_is_transmute(cx, did) {
return None;
}
let typ = ty::node_id_to_type(cx.tcx, expr.id);
let typ = cx.tcx.node_id_to_type(expr.id);
match typ.sty {
ty::TyBareFn(_, ref bare_fn) if bare_fn.abi == RustIntrinsic => {
if let ty::FnConverging(to) = bare_fn.sig.0.output {
@ -2194,11 +2186,11 @@ impl LintPass for MutableTransmutes {
}
fn def_id_is_transmute(cx: &Context, def_id: DefId) -> bool {
match ty::lookup_item_type(cx.tcx, def_id).ty.sty {
match cx.tcx.lookup_item_type(def_id).ty.sty {
ty::TyBareFn(_, ref bfty) if bfty.abi == RustIntrinsic => (),
_ => return false
}
ty::with_path(cx.tcx, def_id, |path| match path.last() {
cx.tcx.with_path(def_id, |path| match path.last() {
Some(ref last) => last.name().as_str() == "transmute",
_ => false
})
@ -2251,7 +2243,7 @@ impl LintPass for DropWithReprExtern {
let (drop_impl_did, dtor_self_type) =
if dtor_did.krate == ast::LOCAL_CRATE {
let impl_did = ctx.tcx.map.get_parent_did(dtor_did.node);
let ty = ty::lookup_item_type(ctx.tcx, impl_did).ty;
let ty = ctx.tcx.lookup_item_type(impl_did).ty;
(impl_did, ty)
} else {
continue;
@ -2261,9 +2253,9 @@ impl LintPass for DropWithReprExtern {
ty::TyEnum(self_type_did, _) |
ty::TyStruct(self_type_did, _) |
ty::TyClosure(self_type_did, _) => {
let hints = ty::lookup_repr_hints(ctx.tcx, self_type_did);
let hints = ctx.tcx.lookup_repr_hints(self_type_did);
if hints.iter().any(|attr| *attr == attr::ReprExtern) &&
ty::ty_dtor(ctx.tcx, self_type_did).has_drop_flag() {
ctx.tcx.ty_dtor(self_type_did).has_drop_flag() {
let drop_impl_span = ctx.tcx.map.def_id_span(drop_impl_did,
codemap::DUMMY_SP);
let self_defn_span = ctx.tcx.map.def_id_span(self_type_did,

View file

@ -273,7 +273,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
}
_ => true,
};
let tr = ty::impl_trait_ref(self.tcx, local_def(item.id));
let tr = self.tcx.impl_trait_ref(local_def(item.id));
let public_trait = tr.clone().map_or(false, |tr| {
!is_local(tr.def_id) ||
self.exported_items.contains(&tr.def_id.node)
@ -423,7 +423,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
self.def_privacy(id)
}
ty::ImplContainer(id) => {
match ty::impl_trait_ref(self.tcx, id) {
match self.tcx.impl_trait_ref(id) {
Some(t) => {
debug!("privacy - impl of trait {:?}", id);
self.def_privacy(t.def_id)
@ -451,7 +451,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
self.def_privacy(id)
}
ty::ImplContainer(id) => {
match ty::impl_trait_ref(self.tcx, id) {
match self.tcx.impl_trait_ref(id) {
Some(t) => {
debug!("privacy - impl of trait {:?}", id);
self.def_privacy(t.def_id)
@ -476,7 +476,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
self.def_privacy(id)
}
ty::ImplContainer(id) => {
match ty::impl_trait_ref(self.tcx, id) {
match self.tcx.impl_trait_ref(id) {
Some(t) => {
debug!("privacy - impl of trait {:?}", id);
self.def_privacy(t.def_id)
@ -537,7 +537,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
ast::MethodImplItem(..) => {
let imp = self.tcx.map
.get_parent_did(closest_private_id);
match ty::impl_trait_ref(self.tcx, imp) {
match self.tcx.impl_trait_ref(imp) {
Some(..) => return Allowable,
_ if ii.vis == ast::Public => {
return Allowable
@ -696,7 +696,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
span: Span,
id: ast::DefId,
name: FieldName) {
let fields = ty::lookup_struct_fields(self.tcx, id);
let fields = self.tcx.lookup_struct_fields(id);
let field = match name {
NamedField(f_name) => {
debug!("privacy - check named field {} in struct {:?}", f_name, id);
@ -709,10 +709,10 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
return
}
let struct_type = ty::lookup_item_type(self.tcx, id).ty;
let struct_type = self.tcx.lookup_item_type(id).ty;
let struct_desc = match struct_type.sty {
ty::TyStruct(_, _) =>
format!("struct `{}`", ty::item_path_str(self.tcx, id)),
format!("struct `{}`", self.tcx.item_path_str(id)),
// struct variant fields have inherited visibility
ty::TyEnum(..) => return,
_ => self.tcx.sess.span_bug(span, "can't find struct for field")
@ -733,7 +733,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
name: ast::Name) {
// If the method is a default method, we need to use the def_id of
// the default implementation.
let method_id = match ty::impl_or_trait_item(self.tcx, method_id) {
let method_id = match self.tcx.impl_or_trait_item(method_id) {
ty::MethodTraitItem(method_type) => {
method_type.provided_source.unwrap_or(method_id)
}
@ -893,12 +893,12 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &ast::Expr) {
match expr.node {
ast::ExprField(ref base, ident) => {
if let ty::TyStruct(id, _) = ty::expr_ty_adjusted(self.tcx, &**base).sty {
if let ty::TyStruct(id, _) = self.tcx.expr_ty_adjusted(&**base).sty {
self.check_field(expr.span, id, NamedField(ident.node.name));
}
}
ast::ExprTupField(ref base, idx) => {
if let ty::TyStruct(id, _) = ty::expr_ty_adjusted(self.tcx, &**base).sty {
if let ty::TyStruct(id, _) = self.tcx.expr_ty_adjusted(&**base).sty {
self.check_field(expr.span, id, UnnamedField(idx.node));
}
}
@ -917,12 +917,12 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
}
}
ast::ExprStruct(_, ref fields, _) => {
match ty::expr_ty(self.tcx, expr).sty {
match self.tcx.expr_ty(expr).sty {
ty::TyStruct(ctor_id, _) => {
// RFC 736: ensure all unmentioned fields are visible.
// Rather than computing the set of unmentioned fields
// (i.e. `all_fields - fields`), just check them all.
let all_fields = ty::lookup_struct_fields(self.tcx, ctor_id);
let all_fields = self.tcx.lookup_struct_fields(ctor_id);
for field in all_fields {
self.check_field(expr.span, ctor_id,
NamedField(field.name));
@ -950,7 +950,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
}
ast::ExprPath(..) => {
let guard = |did: ast::DefId| {
let fields = ty::lookup_struct_fields(self.tcx, did);
let fields = self.tcx.lookup_struct_fields(did);
let any_priv = fields.iter().any(|f| {
f.vis != ast::Public && (
!is_local(f.id) ||
@ -994,7 +994,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
match pattern.node {
ast::PatStruct(_, ref fields, _) => {
match ty::pat_ty(self.tcx, pattern).sty {
match self.tcx.pat_ty(pattern).sty {
ty::TyStruct(id, _) => {
for field in fields {
self.check_field(pattern.span, id,
@ -1025,7 +1025,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
// Patterns which bind no fields are allowable (the path is check
// elsewhere).
ast::PatEnum(_, Some(ref fields)) => {
match ty::pat_ty(self.tcx, pattern).sty {
match self.tcx.pat_ty(pattern).sty {
ty::TyStruct(id, _) => {
for (i, field) in fields.iter().enumerate() {
if let ast::PatWild(..) = field.node {
@ -1337,7 +1337,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
let not_private_trait =
trait_ref.as_ref().map_or(true, // no trait counts as public trait
|tr| {
let did = ty::trait_ref_to_def_id(self.tcx, tr);
let did = self.tcx.trait_ref_to_def_id(tr);
!is_local(did) || self.trait_is_public(did.node)
});

View file

@ -311,7 +311,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
let mut scope_id;
// The qualname for a method is the trait name or name of the struct in an impl in
// which the method is declared in, followed by the method's name.
let qualname = match ty::impl_of_method(self.tcx, ast_util::local_def(id)) {
let qualname = match self.tcx.impl_of_method(ast_util::local_def(id)) {
Some(impl_id) => match self.tcx.map.get(impl_id.node) {
NodeItem(item) => {
scope_id = item.id;
@ -320,11 +320,11 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
let mut result = String::from("<");
result.push_str(&ty_to_string(&**ty));
match ty::trait_of_item(self.tcx, ast_util::local_def(id)) {
match self.tcx.trait_of_item(ast_util::local_def(id)) {
Some(def_id) => {
result.push_str(" as ");
result.push_str(
&ty::item_path_str(self.tcx, def_id));
&self.tcx.item_path_str(def_id));
},
None => {}
}
@ -344,12 +344,12 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
impl_id.node, id, self.tcx.map.get(impl_id.node)));
},
},
None => match ty::trait_of_item(self.tcx, ast_util::local_def(id)) {
None => match self.tcx.trait_of_item(ast_util::local_def(id)) {
Some(def_id) => {
scope_id = def_id.node;
match self.tcx.map.get(def_id.node) {
NodeItem(_) => {
format!("::{}", ty::item_path_str(self.tcx, def_id))
format!("::{}", self.tcx.item_path_str(def_id))
}
_ => {
self.sess.span_bug(span,
@ -368,7 +368,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
let qualname = &format!("{}::{}", qualname, &token::get_name(name));
// record the decl for this def (if it has one)
let decl_id = ty::trait_item_of_item(self.tcx, ast_util::local_def(id))
let decl_id = self.tcx.trait_item_of_item(ast_util::local_def(id))
.and_then(|new_id| {
let def_id = new_id.def_id();
if def_id.node != 0 && def_id != ast_util::local_def(id) {
@ -776,10 +776,10 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
def::DefMethod(declid, provenence) => {
let sub_span = self.span.sub_span_for_meth_name(span);
let defid = if declid.krate == ast::LOCAL_CRATE {
let ti = ty::impl_or_trait_item(self.tcx, declid);
let ti = self.tcx.impl_or_trait_item(declid);
match provenence {
def::FromTrait(def_id) => {
Some(ty::trait_items(self.tcx, def_id)
Some(self.tcx.trait_items(def_id)
.iter()
.find(|mr| {
mr.name() == ti.name()
@ -793,10 +793,8 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
.unwrap()
.iter()
.find(|mr| {
ty::impl_or_trait_item(
self.tcx,
mr.def_id()
).name() == ti.name()
self.tcx.impl_or_trait_item(mr.def_id()).name()
== ti.name()
})
.unwrap()
.def_id())
@ -826,7 +824,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
// modules or types in the path prefix
match def {
def::DefMethod(did, _) => {
let ti = ty::impl_or_trait_item(self.tcx, did);
let ti = self.tcx.impl_or_trait_item(did);
if let ty::MethodTraitItem(m) = ti {
if m.explicit_self == ty::StaticExplicitSelfCategory {
self.write_sub_path_trait_truncated(path);
@ -895,14 +893,14 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
ty::MethodStaticClosure(def_id) => {
// method invoked on an object with a concrete type (not a static method)
let decl_id =
match ty::trait_item_of_item(self.tcx, def_id) {
match self.tcx.trait_item_of_item(def_id) {
None => None,
Some(decl_id) => Some(decl_id.def_id()),
};
// This incantation is required if the method referenced is a
// trait's default implementation.
let def_id = match ty::impl_or_trait_item(self.tcx, def_id) {
let def_id = match self.tcx.impl_or_trait_item(def_id) {
ty::MethodTraitItem(method) => {
method.provided_source.unwrap_or(def_id)
}
@ -915,16 +913,14 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
}
ty::MethodTypeParam(ref mp) => {
// method invoked on a type parameter
let trait_item = ty::trait_item(self.tcx,
mp.trait_ref.def_id,
mp.method_num);
let trait_item = self.tcx.trait_item(mp.trait_ref.def_id,
mp.method_num);
(None, Some(trait_item.def_id()))
}
ty::MethodTraitObject(ref mo) => {
// method invoked on a trait instance
let trait_item = ty::trait_item(self.tcx,
mo.trait_ref.def_id,
mo.method_num);
let trait_item = self.tcx.trait_item(mo.trait_ref.def_id,
mo.method_num);
(None, Some(trait_item.def_id()))
}
};
@ -953,7 +949,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
def::DefConst(..) | def::DefAssociatedConst(..) => None,
def::DefVariant(_, variant_id, _) => Some(variant_id),
_ => {
match ty::ty_to_def_id(ty::node_id_to_type(self.tcx, p.id)) {
match self.tcx.node_id_to_type(p.id).ty_to_def_id() {
None => {
self.sess.span_bug(p.span,
&format!("Could not find struct_def for `{}`",
@ -965,7 +961,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
};
if let Some(struct_def) = struct_def {
let struct_fields = ty::lookup_struct_fields(self.tcx, struct_def);
let struct_fields = self.tcx.lookup_struct_fields(struct_def);
for &Spanned { node: ref field, span } in fields {
let sub_span = self.span.span_for_first_ident(span);
for f in &struct_fields {
@ -1252,10 +1248,10 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
self.visit_expr(&**sub_ex);
let ty = &ty::expr_ty_adjusted(self.tcx, &**sub_ex).sty;
let ty = &self.tcx.expr_ty_adjusted(&**sub_ex).sty;
match *ty {
ty::TyStruct(def_id, _) => {
let fields = ty::lookup_struct_fields(self.tcx, def_id);
let fields = self.tcx.lookup_struct_fields(def_id);
for (i, f) in fields.iter().enumerate() {
if i == idx.node {
let sub_span = self.span.sub_span_after_token(ex.span, token::Dot);

View file

@ -327,10 +327,10 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> {
match expr.node {
ast::ExprField(ref sub_ex, ident) => {
let ty = &ty::expr_ty_adjusted(self.tcx, &sub_ex).sty;
let ty = &self.tcx.expr_ty_adjusted(&sub_ex).sty;
match *ty {
ty::TyStruct(def_id, _) => {
let fields = ty::lookup_struct_fields(self.tcx, def_id);
let fields = self.tcx.lookup_struct_fields(def_id);
for f in &fields {
if f.name == ident.node.name {
let sub_span = self.span_utils.span_for_last_ident(expr.span);
@ -354,7 +354,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
}
}
ast::ExprStruct(ref path, _, _) => {
let ty = &ty::expr_ty_adjusted(&self.tcx, expr).sty;
let ty = &self.tcx.expr_ty_adjusted(expr).sty;
match *ty {
ty::TyStruct(def_id, _) => {
let sub_span = self.span_utils.span_for_last_ident(path.span);
@ -384,7 +384,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
struct_id: DefId,
parent: NodeId)
-> VariableRefData {
let fields = ty::lookup_struct_fields(&self.tcx, struct_id);
let fields = self.tcx.lookup_struct_fields(struct_id);
let field_name = get_ident(field_ref.ident.node).to_string();
for f in &fields {
if f.name == field_ref.ident.node.name {

View file

@ -197,6 +197,7 @@ use middle::def::{self, DefMap};
use middle::expr_use_visitor as euv;
use middle::lang_items::StrEqFnLangItem;
use middle::mem_categorization as mc;
use middle::mem_categorization::Typer;
use middle::pat_util::*;
use trans::adt;
use trans::base::*;
@ -235,7 +236,7 @@ struct ConstantExpr<'a>(&'a ast::Expr);
impl<'a> ConstantExpr<'a> {
fn eq(self, other: ConstantExpr<'a>, tcx: &ty::ctxt) -> bool {
match const_eval::compare_lit_exprs(tcx, self.0, other.0, None,
|id| {ty::node_id_item_substs(tcx, id).substs}) {
|id| {tcx.node_id_item_substs(id).substs}) {
Some(result) => result == Ordering::Equal,
None => panic!("compare_list_exprs: type mismatch"),
}
@ -279,7 +280,7 @@ impl<'a, 'tcx> Opt<'a, 'tcx> {
let ccx = bcx.ccx();
match *self {
ConstantValue(ConstantExpr(lit_expr), _) => {
let lit_ty = ty::node_id_to_type(bcx.tcx(), lit_expr.id);
let lit_ty = bcx.tcx().node_id_to_type(lit_expr.id);
let (llval, _) = consts::const_expr(ccx, &*lit_expr, bcx.fcx.param_substs, None);
let lit_datum = immediate_rvalue(llval, lit_ty);
let lit_datum = unpack_datum!(bcx, lit_datum.to_appropriate_datum(bcx));
@ -562,7 +563,7 @@ fn enter_opt<'a, 'p, 'blk, 'tcx>(
check_match::Constructor::Variant(def_id)
};
let param_env = ty::empty_parameter_environment(bcx.tcx());
let param_env = bcx.tcx().empty_parameter_environment();
let mcx = check_match::MatchCheckCtxt {
tcx: bcx.tcx(),
param_env: param_env,
@ -603,7 +604,7 @@ fn get_branches<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let opt_def = tcx.def_map.borrow().get(&cur.id).map(|d| d.full_def());
match opt_def {
Some(def::DefVariant(enum_id, var_id, _)) => {
let variant = ty::enum_variant_with_id(tcx, enum_id, var_id);
let variant = tcx.enum_variant_with_id(enum_id, var_id);
Variant(variant.disr_val,
adt::represent_node(bcx, cur.id),
var_id,
@ -1067,7 +1068,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
let mcx = check_match::MatchCheckCtxt {
tcx: bcx.tcx(),
param_env: ty::empty_parameter_environment(bcx.tcx()),
param_env: bcx.tcx().empty_parameter_environment(),
};
let adt_vals = if any_irrefutable_adt_pat(bcx.tcx(), m, col) {
let repr = adt::represent_type(bcx.ccx(), left_ty);
@ -1090,9 +1091,9 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
// The last field is technically unsized but
// since we can only ever match that field behind
// a reference we construct a fat ptr here.
let fields = ty::lookup_struct_fields(bcx.tcx(), def_id);
let fields = bcx.tcx().lookup_struct_fields(def_id);
let unsized_ty = fields.iter().last().map(|field| {
let fty = ty::lookup_field_type(bcx.tcx(), def_id, field.id, substs);
let fty = bcx.tcx().lookup_field_type(def_id, field.id, substs);
monomorphize::normalize_associated_type(bcx.tcx(), &fty)
}).unwrap();
let llty = type_of::type_of(bcx.ccx(), unsized_ty);
@ -1409,13 +1410,13 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
let variable_ty = node_id_type(bcx, p_id);
let llvariable_ty = type_of::type_of(ccx, variable_ty);
let tcx = bcx.tcx();
let param_env = ty::empty_parameter_environment(tcx);
let param_env = tcx.empty_parameter_environment();
let llmatch;
let trmode;
match bm {
ast::BindByValue(_)
if !ty::type_moves_by_default(&param_env, span, variable_ty) || reassigned =>
if !param_env.type_moves_by_default(variable_ty, span) || reassigned =>
{
llmatch = alloca_no_lifetime(bcx,
llvariable_ty.ptr_to(),
@ -1468,7 +1469,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
}
let t = node_id_type(bcx, discr_expr.id);
let chk = if ty::type_is_empty(tcx, t) {
let chk = if t.is_empty(tcx) {
Unreachable
} else {
Infallible
@ -1747,9 +1748,7 @@ fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
match opt_def {
Some(def::DefVariant(enum_id, var_id, _)) => {
let repr = adt::represent_node(bcx, pat.id);
let vinfo = ty::enum_variant_with_id(ccx.tcx(),
enum_id,
var_id);
let vinfo = ccx.tcx().enum_variant_with_id(enum_id, var_id);
let args = extract_variant_args(bcx,
&*repr,
vinfo.disr_val,
@ -1789,7 +1788,7 @@ fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let pat_repr = adt::represent_type(bcx.ccx(), pat_ty);
expr::with_field_tys(tcx, pat_ty, Some(pat.id), |discr, field_tys| {
for f in fields {
let ix = ty::field_idx_strict(tcx, f.node.ident.name, field_tys);
let ix = tcx.field_idx_strict(f.node.ident.name, field_tys);
let fldptr = adt::trans_field_ptr(bcx, &*pat_repr, val,
discr, ix);
bcx = bind_irrefutable_pat(bcx, &*f.node.pat, fldptr, cleanup_scope);

View file

@ -209,13 +209,13 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
Univariant(mk_struct(cx, &elems[..], false, t), 0)
}
ty::TyStruct(def_id, substs) => {
let fields = ty::lookup_struct_fields(cx.tcx(), def_id);
let fields = cx.tcx().lookup_struct_fields(def_id);
let mut ftys = fields.iter().map(|field| {
let fty = ty::lookup_field_type(cx.tcx(), def_id, field.id, substs);
let fty = cx.tcx().lookup_field_type(def_id, field.id, substs);
monomorphize::normalize_associated_type(cx.tcx(), &fty)
}).collect::<Vec<_>>();
let packed = ty::lookup_packed(cx.tcx(), def_id);
let dtor = ty::ty_dtor(cx.tcx(), def_id).has_drop_flag();
let packed = cx.tcx().lookup_packed(def_id);
let dtor = cx.tcx().ty_dtor(def_id).has_drop_flag();
if dtor {
ftys.push(cx.tcx().dtor_type());
}
@ -230,10 +230,10 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}
ty::TyEnum(def_id, substs) => {
let cases = get_cases(cx.tcx(), def_id, substs);
let hint = *ty::lookup_repr_hints(cx.tcx(), def_id).get(0)
let hint = *cx.tcx().lookup_repr_hints(def_id).get(0)
.unwrap_or(&attr::ReprAny);
let dtor = ty::ty_dtor(cx.tcx(), def_id).has_drop_flag();
let dtor = cx.tcx().ty_dtor(def_id).has_drop_flag();
if cases.is_empty() {
// Uninhabitable; represent as unit
@ -261,9 +261,8 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// been rejected by a checker before this point.
if !cases.iter().enumerate().all(|(i,c)| c.discr == (i as Disr)) {
cx.sess().bug(&format!("non-C-like enum {} with specified \
discriminants",
ty::item_path_str(cx.tcx(),
def_id)));
discriminants",
cx.tcx().item_path_str(def_id)));
}
if cases.len() == 1 {
@ -411,9 +410,9 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
// Is this the NonZero lang item wrapping a pointer or integer type?
ty::TyStruct(did, substs) if Some(did) == tcx.lang_items.non_zero() => {
let nonzero_fields = ty::lookup_struct_fields(tcx, did);
let nonzero_fields = tcx.lookup_struct_fields(did);
assert_eq!(nonzero_fields.len(), 1);
let nonzero_field = ty::lookup_field_type(tcx, did, nonzero_fields[0].id, substs);
let nonzero_field = tcx.lookup_field_type(did, nonzero_fields[0].id, substs);
match nonzero_field.sty {
ty::TyRawPtr(ty::mt { ty, .. }) if !type_is_sized(tcx, ty) => {
path.push_all(&[0, FAT_PTR_ADDR]);
@ -430,9 +429,9 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
// Perhaps one of the fields of this struct is non-zero
// let's recurse and find out
ty::TyStruct(def_id, substs) => {
let fields = ty::lookup_struct_fields(tcx, def_id);
let fields = tcx.lookup_struct_fields(def_id);
for (j, field) in fields.iter().enumerate() {
let field_ty = ty::lookup_field_type(tcx, def_id, field.id, substs);
let field_ty = tcx.lookup_field_type(def_id, field.id, substs);
if let Some(mut fpath) = find_discr_field_candidate(tcx, field_ty, path.clone()) {
fpath.push(j);
return Some(fpath);
@ -504,7 +503,7 @@ fn get_cases<'tcx>(tcx: &ty::ctxt<'tcx>,
def_id: ast::DefId,
substs: &subst::Substs<'tcx>)
-> Vec<Case<'tcx>> {
ty::enum_variants(tcx, def_id).iter().map(|vi| {
tcx.enum_variants(def_id).iter().map(|vi| {
let arg_tys = vi.args.iter().map(|&raw_ty| {
monomorphize::apply_param_substs(tcx, substs, &raw_ty)
}).collect();

View file

@ -153,7 +153,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
_ => ccx.sess().bug("expected closure or function.")
};
let fn_sig = ty::erase_late_bound_regions(ccx.tcx(), fn_sig);
let fn_sig = ccx.tcx().erase_late_bound_regions(fn_sig);
let mut attrs = llvm::AttrBuilder::new();
let ret_ty = fn_sig.output;
@ -274,7 +274,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
// `&T` where `T` contains no `UnsafeCell<U>` is immutable, and can be marked as
// both `readonly` and `noalias`, as LLVM's definition of `noalias` is based solely
// on memory dependencies rather than pointer equality
let interior_unsafe = ty::type_contents(ccx.tcx(), mt.ty).interior_unsafe();
let interior_unsafe = mt.ty.type_contents(ccx.tcx()).interior_unsafe();
if mt.mutbl == ast::MutMutable || !interior_unsafe {
attrs.arg(idx, llvm::Attribute::NoAlias);

View file

@ -232,7 +232,7 @@ pub fn get_extern_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, did: ast::DefId,
// don't do this then linker errors can be generated where the linker
// complains that one object files has a thread local version of the
// symbol and another one doesn't.
for attr in ty::get_attrs(ccx.tcx(), did).iter() {
for attr in ccx.tcx().get_attrs(did).iter() {
if attr.check_name("thread_local") {
llvm::set_thread_local(c, true);
}
@ -462,7 +462,7 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
let ccx = fcx.ccx;
let repr = adt::represent_type(ccx, t);
let variants = ty::enum_variants(ccx.tcx(), tid);
let variants = ccx.tcx().enum_variants(tid);
let n_variants = (*variants).len();
// NB: we must hit the discriminant first so that structural
@ -1216,7 +1216,7 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
llfn: llfndecl,
llenv: None,
llretslotptr: Cell::new(None),
param_env: ty::empty_parameter_environment(ccx.tcx()),
param_env: ccx.tcx().empty_parameter_environment(),
alloca_insert_pt: Cell::new(None),
llreturn: Cell::new(None),
needs_ret_allocas: nested_returns,
@ -1668,8 +1668,8 @@ pub fn trans_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
let _s = StatRecorder::new(ccx, ccx.tcx().map.path_to_string(id).to_string());
debug!("trans_fn(param_substs={:?})", param_substs);
let _icx = push_ctxt("trans_fn");
let fn_ty = ty::node_id_to_type(ccx.tcx(), id);
let output_type = ty::erase_late_bound_regions(ccx.tcx(), &fn_ty.fn_ret());
let fn_ty = ccx.tcx().node_id_to_type(id);
let output_type = ccx.tcx().erase_late_bound_regions(&fn_ty.fn_ret());
let abi = fn_ty.fn_abi();
trans_closure(ccx, decl, body, llfndecl, param_substs, id, attrs, output_type, abi,
closure::ClosureEnv::NotClosure);
@ -1704,7 +1704,7 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
let result_ty = match ctor_ty.sty {
ty::TyBareFn(_, ref bft) => {
ty::erase_late_bound_regions(bcx.tcx(), &bft.sig.output()).unwrap()
bcx.tcx().erase_late_bound_regions(&bft.sig.output()).unwrap()
}
_ => ccx.sess().bug(
&format!("trans_enum_variant_constructor: \
@ -1777,12 +1777,12 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
disr: ty::Disr,
param_substs: &'tcx Substs<'tcx>,
llfndecl: ValueRef) {
let ctor_ty = ty::node_id_to_type(ccx.tcx(), ctor_id);
let ctor_ty = ccx.tcx().node_id_to_type(ctor_id);
let ctor_ty = monomorphize::apply_param_substs(ccx.tcx(), param_substs, &ctor_ty);
let result_ty = match ctor_ty.sty {
ty::TyBareFn(_, ref bft) => {
ty::erase_late_bound_regions(ccx.tcx(), &bft.sig.output())
ccx.tcx().erase_late_bound_regions(&bft.sig.output())
}
_ => ccx.sess().bug(
&format!("trans_enum_variant_or_tuple_like_struct: \
@ -1798,9 +1798,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
assert!(!fcx.needs_ret_allocas);
let arg_tys =
ty::erase_late_bound_regions(
ccx.tcx(), &ctor_ty.fn_args());
let arg_tys = ccx.tcx().erase_late_bound_regions(&ctor_ty.fn_args());
let arg_datums = create_datums_for_fn_args(bcx, &arg_tys[..]);
@ -1836,7 +1834,7 @@ fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &ast::EnumDef, sp: Span,
return
}
let ty = ty::node_id_to_type(ccx.tcx(), id);
let ty = ccx.tcx().node_id_to_type(id);
let avar = adt::represent_type(ccx, ty);
match *avar {
adt::General(_, ref variants, _) => {
@ -2035,7 +2033,7 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
// error in trans. This is used to write compile-fail tests
// that actually test that compilation succeeds without
// reporting an error.
if ty::has_attr(ccx.tcx(), local_def(item.id), "rustc_error") {
if ccx.tcx().has_attr(local_def(item.id), "rustc_error") {
ccx.tcx().sess.span_fatal(item.span, "compilation successful");
}
}
@ -2314,7 +2312,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
debug!("get_item_val: id={} item={:?}", id, item);
let val = match item {
ast_map::NodeItem(i) => {
let ty = ty::node_id_to_type(ccx.tcx(), i.id);
let ty = ccx.tcx().node_id_to_type(i.id);
let sym = || exported_name(ccx, id, ty, &i.attrs);
let v = match i.node {
@ -2421,7 +2419,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
match ni.node {
ast::ForeignItemFn(..) => {
let abi = ccx.tcx().map.get_foreign_abi(id);
let ty = ty::node_id_to_type(ccx.tcx(), ni.id);
let ty = ccx.tcx().node_id_to_type(ni.id);
let name = foreign::link_name(&*ni);
let llfn = foreign::register_foreign_item_fn(ccx, abi, ty, &name);
attributes::from_fn_attrs(ccx, &ni.attrs, llfn);
@ -2442,7 +2440,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
}
};
assert!(!args.is_empty());
let ty = ty::node_id_to_type(ccx.tcx(), id);
let ty = ccx.tcx().node_id_to_type(id);
let parent = ccx.tcx().map.get_parent(id);
let enm = ccx.tcx().map.expect_item(parent);
let sym = exported_name(ccx,
@ -2471,7 +2469,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
};
let parent = ccx.tcx().map.get_parent(id);
let struct_item = ccx.tcx().map.expect_item(parent);
let ty = ty::node_id_to_type(ccx.tcx(), ctor_id);
let ty = ccx.tcx().node_id_to_type(ctor_id);
let sym = exported_name(ccx,
id,
ty,
@ -2503,7 +2501,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
fn register_method(ccx: &CrateContext, id: ast::NodeId,
attrs: &[ast::Attribute], span: Span) -> ValueRef {
let mty = ty::node_id_to_type(ccx.tcx(), id);
let mty = ccx.tcx().node_id_to_type(id);
let sym = exported_name(ccx, id, mty, &attrs);

View file

@ -173,7 +173,7 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
bcx.fcx.param_substs).val)
}
def::DefVariant(tid, vid, _) => {
let vinfo = ty::enum_variant_with_id(bcx.tcx(), tid, vid);
let vinfo = bcx.tcx().enum_variant_with_id(tid, vid);
let substs = common::node_id_substs(bcx.ccx(),
ExprId(ref_expr.id),
bcx.fcx.param_substs);
@ -307,7 +307,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
bare_fn_ty));
}
};
let sig = ty::erase_late_bound_regions(tcx, sig);
let sig = tcx.erase_late_bound_regions(sig);
let tuple_input_ty = tcx.mk_tup(sig.inputs.to_vec());
let tuple_fn_ty = tcx.mk_fn(opt_def_id,
tcx.mk_bare_fn(ty::BareFnTy {
@ -406,17 +406,17 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>(
let substs = substs.erase_regions();
// Load the info for the appropriate trait if necessary.
match ty::trait_of_item(tcx, def_id) {
match tcx.trait_of_item(def_id) {
None => {}
Some(trait_id) => {
ty::populate_implementations_for_trait_if_necessary(tcx, trait_id)
tcx.populate_implementations_for_trait_if_necessary(trait_id)
}
}
// We need to do a bunch of special handling for default methods.
// We need to modify the def_id and our substs in order to monomorphize
// the function.
let (is_default, def_id, substs) = match ty::provided_source(tcx, def_id) {
let (is_default, def_id, substs) = match tcx.provided_source(def_id) {
None => {
(false, def_id, tcx.mk_substs(substs))
}
@ -434,16 +434,16 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>(
// So, what we need to do is find this substitution and
// compose it with the one we already have.
let impl_id = ty::impl_or_trait_item(tcx, def_id).container()
let impl_id = tcx.impl_or_trait_item(def_id).container()
.id();
let impl_or_trait_item = ty::impl_or_trait_item(tcx, source_id);
let impl_or_trait_item = tcx.impl_or_trait_item(source_id);
match impl_or_trait_item {
ty::MethodTraitItem(method) => {
let trait_ref = ty::impl_trait_ref(tcx, impl_id).unwrap();
let trait_ref = tcx.impl_trait_ref(impl_id).unwrap();
// Compute the first substitution
let first_subst =
ty::make_substs_for_receiver_types(tcx, &trait_ref, &*method)
tcx.make_substs_for_receiver_types(&trait_ref, &*method)
.erase_regions();
// And compose them
@ -516,7 +516,7 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>(
// Monotype of the REFERENCE to the function (type params
// are subst'd)
let ref_ty = match node {
ExprId(id) => ty::node_id_to_type(tcx, id),
ExprId(id) => tcx.node_id_to_type(id),
MethodCallKey(method_call) => {
tcx.method_map.borrow().get(&method_call).unwrap().ty
}
@ -534,7 +534,7 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>(
}
// Type scheme of the function item (may have type params)
let fn_type_scheme = ty::lookup_item_type(tcx, def_id);
let fn_type_scheme = tcx.lookup_item_type(def_id);
let fn_type = monomorphize::normalize_associated_type(tcx, &fn_type_scheme.ty);
// Find the actual function pointer.
@ -640,7 +640,7 @@ pub fn trans_lang_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
debug_loc: DebugLoc)
-> Result<'blk, 'tcx> {
let fty = if did.krate == ast::LOCAL_CRATE {
ty::node_id_to_type(bcx.tcx(), did.node)
bcx.tcx().node_id_to_type(did.node)
} else {
csearch::get_type(bcx.tcx(), did).ty
};
@ -692,7 +692,7 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
let (abi, ret_ty) = match callee_ty.sty {
ty::TyBareFn(_, ref f) => {
let output = ty::erase_late_bound_regions(bcx.tcx(), &f.sig.output());
let output = bcx.tcx().erase_late_bound_regions(&f.sig.output());
(f.abi, output)
}
_ => panic!("expected bare rust fn or closure in trans_call_inner")
@ -914,9 +914,7 @@ fn trans_args_under_call_abi<'blk, 'tcx>(
ignore_self: bool)
-> Block<'blk, 'tcx>
{
let args =
ty::erase_late_bound_regions(
bcx.tcx(), &fn_ty.fn_args());
let args = bcx.tcx().erase_late_bound_regions(&fn_ty.fn_args());
// Translate the `self` argument first.
if !ignore_self {
@ -977,7 +975,7 @@ fn trans_overloaded_call_args<'blk, 'tcx>(
ignore_self: bool)
-> Block<'blk, 'tcx> {
// Translate the `self` argument first.
let arg_tys = ty::erase_late_bound_regions(bcx.tcx(), &fn_ty.fn_args());
let arg_tys = bcx.tcx().erase_late_bound_regions( &fn_ty.fn_args());
if !ignore_self {
let arg_datum = unpack_datum!(bcx, expr::trans(bcx, arg_exprs[0]));
bcx = trans_arg_datum(bcx,
@ -1023,7 +1021,7 @@ pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
debug!("trans_args(abi={})", abi);
let _icx = push_ctxt("trans_args");
let arg_tys = ty::erase_late_bound_regions(cx.tcx(), &fn_ty.fn_args());
let arg_tys = cx.tcx().erase_late_bound_regions(&fn_ty.fn_args());
let variadic = fn_ty.fn_sig().0.variadic;
let mut bcx = cx;

View file

@ -135,7 +135,7 @@ pub fn get_or_create_declaration_if_closure<'a, 'tcx>(ccx: &CrateContext<'a, 'tc
return None
}
let function_type = ty::node_id_to_type(ccx.tcx(), closure_id.node);
let function_type = ccx.tcx().node_id_to_type(closure_id.node);
let function_type = monomorphize::apply_param_substs(ccx.tcx(), substs, &function_type);
// Normalize type so differences in regions and typedefs don't cause
@ -218,9 +218,9 @@ pub fn trans_closure_expr<'a, 'tcx>(dest: Dest<'a, 'tcx>,
let function_type = typer.closure_type(closure_id, param_substs);
let freevars: Vec<ty::Freevar> =
ty::with_freevars(tcx, id, |fv| fv.iter().cloned().collect());
tcx.with_freevars(id, |fv| fv.iter().cloned().collect());
let sig = ty::erase_late_bound_regions(tcx, &function_type.sig);
let sig = tcx.erase_late_bound_regions(&function_type.sig);
trans_closure(ccx,
decl,
@ -392,7 +392,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
ccx.sess().bug(&format!("symbol `{}` already defined", function_name));
});
let sig = ty::erase_late_bound_regions(tcx, &llonce_bare_fn_ty.sig);
let sig = tcx.erase_late_bound_regions(&llonce_bare_fn_ty.sig);
let (block_arena, fcx): (TypedArena<_>, FunctionContext);
block_arena = TypedArena::new();
fcx = new_fn_ctxt(ccx,

View file

@ -23,6 +23,7 @@ use middle::def;
use middle::infer;
use middle::lang_items::LangItem;
use middle::mem_categorization as mc;
use middle::mem_categorization::Typer;
use middle::region;
use middle::subst::{self, Subst, Substs};
use trans::base;
@ -89,7 +90,7 @@ pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T
fn fold_binder<T>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T>
where T : TypeFoldable<'tcx>
{
let u = ty::anonymize_late_bound_regions(self.tcx(), t);
let u = self.tcx().anonymize_late_bound_regions(t);
ty_fold::super_fold_binder(self, &u)
}
@ -119,7 +120,7 @@ pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T
/// Is the type's representation size known at compile time?
pub fn type_is_sized<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
ty::type_is_sized(None, tcx, DUMMY_SP, ty)
ty.is_sized(&tcx.empty_parameter_environment(), DUMMY_SP)
}
pub fn type_is_fat_ptr<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
@ -161,7 +162,7 @@ pub fn type_needs_unwind_cleanup<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<
ty::TyFloat(_) | ty::TyTuple(_) | ty::TyRawPtr(_) => false,
ty::TyEnum(did, substs) =>
ty::enum_variants(tcx, did).iter().any(|v|
tcx.enum_variants(did).iter().any(|v|
v.args.iter().any(|&aty| {
let t = aty.subst(tcx, substs);
type_needs_unwind_cleanup_(tcx, t, tycache)
@ -183,7 +184,7 @@ pub fn type_needs_unwind_cleanup<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<
/// (Note that this implies that if `ty` has a destructor attached,
/// then `type_needs_drop` will definitely return `true` for `ty`.)
pub fn type_needs_drop<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
type_needs_drop_given_env(cx, ty, &ty::empty_parameter_environment(cx))
type_needs_drop_given_env(cx, ty, &cx.empty_parameter_environment())
}
/// Core implementation of type_needs_drop, potentially making use of
@ -195,7 +196,7 @@ fn type_needs_drop_given_env<'a,'tcx>(cx: &ty::ctxt<'tcx>,
// normalized version of the type, and therefore will definitely
// know whether the type implements Copy (and thus needs no
// cleanup/drop/zeroing) ...
let implements_copy = !ty::type_moves_by_default(&param_env, DUMMY_SP, ty);
let implements_copy = !param_env.type_moves_by_default(ty, DUMMY_SP);
if implements_copy { return false; }
@ -210,7 +211,7 @@ fn type_needs_drop_given_env<'a,'tcx>(cx: &ty::ctxt<'tcx>,
// bound attached (see above), it is sound to treat it as having a
// destructor (e.g. zero its memory on move).
let contents = ty::type_contents(cx, ty);
let contents = ty.type_contents(cx);
debug!("type_needs_drop ty={:?} contents={:?}", ty, contents);
contents.needs_drop(cx)
}
@ -218,9 +219,9 @@ fn type_needs_drop_given_env<'a,'tcx>(cx: &ty::ctxt<'tcx>,
fn type_is_newtype_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool {
match ty.sty {
ty::TyStruct(def_id, substs) => {
let fields = ty::lookup_struct_fields(ccx.tcx(), def_id);
let fields = ccx.tcx().lookup_struct_fields(def_id);
fields.len() == 1 && {
let ty = ty::lookup_field_type(ccx.tcx(), def_id, fields[0].id, substs);
let ty = ccx.tcx().lookup_field_type(def_id, fields[0].id, substs);
let ty = monomorphize::normalize_associated_type(ccx.tcx(), &ty);
type_is_immediate(ccx, ty)
}
@ -267,7 +268,7 @@ pub fn type_is_zero_size<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -
/// zero-size, but not all zero-size types use a `void` return type (in order to aid with C ABI
/// compatibility).
pub fn return_type_is_void(ccx: &CrateContext, ty: Ty) -> bool {
ty.is_nil() || ty::type_is_empty(ccx.tcx(), ty)
ty.is_nil() || ty.is_empty(ccx.tcx())
}
/// Generates a unique symbol based off the name given. This is used to create
@ -661,8 +662,8 @@ impl<'blk, 'tcx> mc::Typer<'tcx> for BlockS<'blk, 'tcx> {
Some(self.tcx().upvar_capture_map.borrow().get(&upvar_id).unwrap().clone())
}
fn type_moves_by_default(&self, span: Span, ty: Ty<'tcx>) -> bool {
self.fcx.param_env.type_moves_by_default(span, ty)
fn type_moves_by_default(&self, ty: Ty<'tcx>, span: Span) -> bool {
self.fcx.param_env.type_moves_by_default(ty, span)
}
}
@ -952,7 +953,7 @@ pub fn monomorphize_type<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, t: Ty<'tcx>) -> T
pub fn node_id_type<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, id: ast::NodeId) -> Ty<'tcx> {
let tcx = bcx.tcx();
let t = ty::node_id_to_type(tcx, id);
let t = tcx.node_id_to_type(id);
monomorphize_type(bcx, t)
}
@ -961,7 +962,7 @@ pub fn expr_ty<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, ex: &ast::Expr) -> Ty<'tcx>
}
pub fn expr_ty_adjusted<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, ex: &ast::Expr) -> Ty<'tcx> {
monomorphize_type(bcx, ty::expr_ty_adjusted(bcx.tcx(), ex))
monomorphize_type(bcx, bcx.tcx().expr_ty_adjusted(ex))
}
/// Attempts to resolve an obligation. The result is a shallow vtable resolution -- meaning that we
@ -989,7 +990,7 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
debug!("trans fulfill_obligation: trait_ref={:?} def_id={:?}",
trait_ref, trait_ref.def_id());
ty::populate_implementations_for_trait_if_necessary(tcx, trait_ref.def_id());
tcx.populate_implementations_for_trait_if_necessary(trait_ref.def_id());
let infcx = infer::new_infer_ctxt(tcx);
// Do the initial selection for the obligation. This yields the
@ -1077,7 +1078,7 @@ impl<'a,'tcx> NormalizingClosureTyper<'a,'tcx> {
pub fn new(tcx: &'a ty::ctxt<'tcx>) -> NormalizingClosureTyper<'a,'tcx> {
// Parameter environment is used to give details about type parameters,
// but since we are in trans, everything is fully monomorphized.
NormalizingClosureTyper { param_env: ty::empty_parameter_environment(tcx) }
NormalizingClosureTyper { param_env: tcx.empty_parameter_environment() }
}
}
@ -1111,7 +1112,7 @@ impl<'a,'tcx> ty::ClosureTyper<'tcx> for NormalizingClosureTyper<'a,'tcx> {
{
// the substitutions in `substs` are already monomorphized,
// but we still must normalize associated types
let result = ty::closure_upvars(&self.param_env, def_id, substs);
let result = self.param_env.closure_upvars(def_id, substs);
monomorphize::normalize_associated_type(self.param_env.tcx, &result)
}
}
@ -1187,7 +1188,7 @@ pub fn node_id_substs<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
let substs = match node {
ExprId(id) => {
ty::node_id_item_substs(tcx, id).substs
tcx.node_id_item_substs(id).substs
}
MethodCallKey(method_call) => {
tcx.method_map.borrow().get(&method_call).unwrap().substs.clone()

View file

@ -57,7 +57,7 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit)
C_integral(Type::uint_from_ty(cx, t), u, false)
}
ast::LitInt(i, ast::UnsuffixedIntLit(_)) => {
let lit_int_ty = ty::node_id_to_type(cx.tcx(), e.id);
let lit_int_ty = cx.tcx().node_id_to_type(e.id);
match lit_int_ty.sty {
ty::TyInt(t) => {
C_integral(Type::int_from_ty(cx, t), i as u64, true)
@ -75,7 +75,7 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit)
C_floating(&fs, Type::float_from_ty(cx, t))
}
ast::LitFloatUnsuffixed(ref fs) => {
let lit_float_ty = ty::node_id_to_type(cx.tcx(), e.id);
let lit_float_ty = cx.tcx().node_id_to_type(e.id);
match lit_float_ty.sty {
ty::TyFloat(t) => {
C_floating(&fs, Type::float_from_ty(cx, t))
@ -249,7 +249,7 @@ pub fn get_const_expr_as_global<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
// Avoid autorefs as they would create global instead of stack
// references, even when only the latter are correct.
let ty = monomorphize::apply_param_substs(ccx.tcx(), param_substs,
&ty::expr_ty(ccx.tcx(), expr));
&ccx.tcx().expr_ty(expr));
const_expr_unadjusted(ccx, expr, ty, param_substs, None)
} else {
const_expr(ccx, expr, param_substs, None).0
@ -276,11 +276,11 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn_args: FnArgMap)
-> (ValueRef, Ty<'tcx>) {
let ety = monomorphize::apply_param_substs(cx.tcx(), param_substs,
&ty::expr_ty(cx.tcx(), e));
&cx.tcx().expr_ty(e));
let llconst = const_expr_unadjusted(cx, e, ety, param_substs, fn_args);
let mut llconst = llconst;
let mut ety_adjusted = monomorphize::apply_param_substs(cx.tcx(), param_substs,
&ty::expr_ty_adjusted(cx.tcx(), e));
&cx.tcx().expr_ty_adjusted(e));
let opt_adj = cx.tcx().adjustments.borrow().get(&e.id).cloned();
match opt_adj {
Some(ty::AdjustReifyFnPointer) => {
@ -588,7 +588,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
let (bv, bt) = const_expr(cx, &**base, param_substs, fn_args);
let brepr = adt::represent_type(cx, bt);
expr::with_field_tys(cx.tcx(), bt, None, |discr, field_tys| {
let ix = ty::field_idx_strict(cx.tcx(), field.node.name, field_tys);
let ix = cx.tcx().field_idx_strict(field.node.name, field_tys);
adt::const_get_field(cx, &*brepr, bv, discr, ix)
})
}
@ -803,7 +803,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
ast::ExprRepeat(ref elem, ref count) => {
let unit_ty = ety.sequence_element_type(cx.tcx());
let llunitty = type_of::type_of(cx, unit_ty);
let n = ty::eval_repeat_count(cx.tcx(), count);
let n = cx.tcx().eval_repeat_count(count);
let unit_val = const_expr(cx, &**elem, param_substs, fn_args).0;
let vs: Vec<_> = repeat(unit_val).take(n).collect();
if val_ty(unit_val) != llunitty {
@ -829,9 +829,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
const_deref_ptr(cx, get_const_val(cx, def_id, e))
}
def::DefVariant(enum_did, variant_did, _) => {
let vinfo = ty::enum_variant_with_id(cx.tcx(),
enum_did,
variant_did);
let vinfo = cx.tcx().enum_variant_with_id(enum_did, variant_did);
if !vinfo.args.is_empty() {
// N-ary variant.
expr::trans_def_fn_unadjusted(cx, e, def, param_substs).val
@ -884,9 +882,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}
def::DefVariant(enum_did, variant_did, _) => {
let repr = adt::represent_type(cx, ety);
let vinfo = ty::enum_variant_with_id(cx.tcx(),
enum_did,
variant_did);
let vinfo = cx.tcx().enum_variant_with_id(enum_did, variant_did);
adt::trans_const(cx,
&*repr,
vinfo.disr_val,
@ -945,8 +941,8 @@ pub fn trans_static(ccx: &CrateContext, m: ast::Mutability, id: ast::NodeId) ->
// As an optimization, all shared statics which do not have interior
// mutability are placed into read-only memory.
if m != ast::MutMutable {
let node_ty = ty::node_id_to_type(ccx.tcx(), id);
let tcontents = ty::type_contents(ccx.tcx(), node_ty);
let node_ty = ccx.tcx().node_id_to_type(id);
let tcontents = node_ty.type_contents(ccx.tcx());
if !tcontents.interior_unsafe() {
llvm::LLVMSetGlobalConstant(g, True);
}

View file

@ -101,7 +101,8 @@ use trans::cleanup::CleanupMethods;
use trans::expr;
use trans::tvec;
use trans::type_of;
use middle::ty::{self, Ty};
use middle::mem_categorization::Typer;
use middle::ty::Ty;
use std::fmt;
use syntax::ast;
@ -605,9 +606,8 @@ impl<'tcx, K: KindOps + fmt::Debug> Datum<'tcx, K> {
* affine values (since they must never be duplicated).
*/
assert!(!ty::type_moves_by_default(&ty::empty_parameter_environment(bcx.tcx()),
DUMMY_SP,
self.ty));
assert!(!bcx.tcx().empty_parameter_environment()
.type_moves_by_default(self.ty, DUMMY_SP));
self.shallow_copy_raw(bcx, dst)
}

View file

@ -242,9 +242,7 @@ impl<'tcx> TypeMap<'tcx> {
ty::TyTrait(ref trait_data) => {
unique_type_id.push_str("trait ");
let principal =
ty::erase_late_bound_regions(cx.tcx(),
&trait_data.principal);
let principal = cx.tcx().erase_late_bound_regions(&trait_data.principal);
from_def_id_and_substs(self,
cx,
@ -261,7 +259,7 @@ impl<'tcx> TypeMap<'tcx> {
unique_type_id.push_str(" fn(");
let sig = ty::erase_late_bound_regions(cx.tcx(), sig);
let sig = cx.tcx().erase_late_bound_regions(sig);
for &parameter_type in &sig.inputs {
let parameter_type_id =
@ -376,7 +374,7 @@ impl<'tcx> TypeMap<'tcx> {
unique_type_id.push_str("|");
let sig = ty::erase_late_bound_regions(cx.tcx(), sig);
let sig = cx.tcx().erase_late_bound_regions(sig);
for &parameter_type in &sig.inputs {
let parameter_type_id =
@ -626,7 +624,7 @@ fn subroutine_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
span: Span)
-> MetadataCreationResult
{
let signature = ty::erase_late_bound_regions(cx.tcx(), signature);
let signature = cx.tcx().erase_late_bound_regions(signature);
let mut signature_metadata: Vec<DIType> = Vec::with_capacity(signature.inputs.len() + 1);
@ -1176,7 +1174,7 @@ fn prepare_struct_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
unique_type_id,
containing_scope);
let mut fields = ty::struct_fields(cx.tcx(), def_id, substs);
let mut fields = cx.tcx().struct_fields(def_id, substs);
// The `Ty` values returned by `ty::struct_fields` can still contain
// `TyProjection` variants, so normalize those away.
@ -1588,7 +1586,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
let loc = span_start(cx, definition_span);
let file_metadata = file_metadata(cx, &loc.file.name);
let variants = ty::enum_variants(cx.tcx(), enum_def_id);
let variants = cx.tcx().enum_variants(enum_def_id);
let enumerators_metadata: Vec<DIDescriptor> = variants
.iter()
@ -1891,7 +1889,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
};
let is_local_to_unit = is_node_local_to_unit(cx, node_id);
let variable_type = ty::node_id_to_type(cx.tcx(), node_id);
let variable_type = cx.tcx().node_id_to_type(node_id);
let type_metadata = type_metadata(cx, variable_type, span);
let namespace_node = namespace_for_item(cx, ast_util::local_def(node_id));
let var_name = token::get_name(name).to_string();

View file

@ -30,7 +30,7 @@ use rustc::ast_map;
use trans::common::{NodeIdAndSpan, CrateContext, FunctionContext, Block};
use trans;
use trans::monomorphize;
use middle::ty::{self, Ty, ClosureTyper};
use middle::ty::{Ty, ClosureTyper};
use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
use util::nodemap::{DefIdMap, NodeMap, FnvHashMap, FnvHashSet};
@ -412,7 +412,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// Return type -- llvm::DIBuilder wants this at index 0
assert_type_for_node_id(cx, fn_ast_id, error_reporting_span);
let return_type = ty::node_id_to_type(cx.tcx(), fn_ast_id);
let return_type = cx.tcx().node_id_to_type(fn_ast_id);
let return_type = monomorphize::apply_param_substs(cx.tcx(),
param_substs,
&return_type);
@ -425,7 +425,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// Arguments types
for arg in &fn_decl.inputs {
assert_type_for_node_id(cx, arg.pat.id, arg.pat.span);
let arg_type = ty::node_id_to_type(cx.tcx(), arg.pat.id);
let arg_type = cx.tcx().node_id_to_type(arg.pat.id);
let arg_type = monomorphize::apply_param_substs(cx.tcx(),
param_substs,
&arg_type);

View file

@ -16,7 +16,7 @@ use llvm;
use llvm::debuginfo::DIScope;
use rustc::ast_map;
use trans::common::CrateContext;
use middle::ty::{self, ClosureTyper};
use middle::ty::ClosureTyper;
use std::ffi::CString;
use std::ptr;
@ -56,7 +56,7 @@ pub fn crate_root_namespace<'a>(cx: &'a CrateContext) -> &'a str {
}
pub fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc<NamespaceTreeNode> {
ty::with_path(cx.tcx(), def_id, |path| {
cx.tcx().with_path(def_id, |path| {
// prepend crate name if not already present
let krate = if def_id.krate == ast::LOCAL_CRATE {
let crate_namespace_name = token::intern(crate_root_namespace(cx));

View file

@ -106,7 +106,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
output.push(']');
},
ty::TyTrait(ref trait_data) => {
let principal = ty::erase_late_bound_regions(cx.tcx(), &trait_data.principal);
let principal = cx.tcx().erase_late_bound_regions(&trait_data.principal);
push_item_name(cx, principal.def_id, false, output);
push_type_params(cx, principal.substs, output);
},
@ -123,7 +123,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
output.push_str("fn(");
let sig = ty::erase_late_bound_regions(cx.tcx(), sig);
let sig = cx.tcx().erase_late_bound_regions(sig);
if !sig.inputs.is_empty() {
for &parameter_type in &sig.inputs {
push_debuginfo_type_name(cx, parameter_type, true, output);
@ -170,7 +170,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
def_id: ast::DefId,
qualified: bool,
output: &mut String) {
ty::with_path(cx.tcx(), def_id, |path| {
cx.tcx().with_path(def_id, |path| {
if qualified {
if def_id.krate == ast::LOCAL_CRATE {
output.push_str(crate_root_namespace(cx));

View file

@ -128,7 +128,7 @@ pub fn declare_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
_ => ccx.sess().bug("expected closure or fn")
};
let sig = ty::Binder(ty::erase_late_bound_regions(ccx.tcx(), sig));
let sig = ty::Binder(ccx.tcx().erase_late_bound_regions(sig));
debug!("declare_rust_fn (after region erasure) sig={:?}", sig);
let llfty = type_of::type_of_rust_fn(ccx, env, &sig, abi);
debug!("declare_rust_fn llfty={}", ccx.tn().type_to_string(llfty));

View file

@ -73,7 +73,6 @@ use trans::monomorphize;
use trans::tvec;
use trans::type_of;
use middle::cast::{CastKind, CastTy};
use middle::ty::{struct_fields, tup_fields};
use middle::ty::{AdjustDerefRef, AdjustReifyFnPointer, AdjustUnsafeFnPointer};
use middle::ty::{self, Ty};
use middle::ty::MethodCall;
@ -313,7 +312,7 @@ pub fn unsized_info<'ccx, 'tcx>(ccx: &CrateContext<'ccx, 'tcx>,
old_info: Option<ValueRef>,
param_substs: &'tcx Substs<'tcx>)
-> ValueRef {
let (source, target) = ty::struct_lockstep_tails(ccx.tcx(), source, target);
let (source, target) = ccx.tcx().struct_lockstep_tails(source, target);
match (&source.sty, &target.sty) {
(&ty::TyArray(_, len), &ty::TySlice(_)) => C_uint(ccx, len),
(&ty::TyTrait(_), &ty::TyTrait(_)) => {
@ -500,7 +499,7 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let kind = match fulfill_obligation(bcx.ccx(), span, trait_ref) {
traits::VtableImpl(traits::VtableImplData { impl_def_id, .. }) => {
ty::custom_coerce_unsized_kind(bcx.tcx(), impl_def_id)
bcx.tcx().custom_coerce_unsized_kind(impl_def_id)
}
vtable => {
bcx.sess().span_bug(span, &format!("invalid CoerceUnsized vtable: {:?}",
@ -748,7 +747,7 @@ fn trans_rec_field<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
base: &ast::Expr,
field: ast::Name)
-> DatumBlock<'blk, 'tcx, Expr> {
trans_field(bcx, base, |tcx, field_tys| ty::field_idx_strict(tcx, field, field_tys))
trans_field(bcx, base, |tcx, field_tys| tcx.field_idx_strict(field, field_tys))
}
/// Translates `base.<idx>`.
@ -789,8 +788,7 @@ fn trans_index<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let ix_datum = unpack_datum!(bcx, trans(bcx, idx));
let ref_ty = // invoked methods have LB regions instantiated:
ty::no_late_bound_regions(
bcx.tcx(), &method_ty.fn_ret()).unwrap().unwrap();
bcx.tcx().no_late_bound_regions(&method_ty.fn_ret()).unwrap().unwrap();
let elt_ty = match ref_ty.builtin_deref(true) {
None => {
bcx.tcx().sess.span_bug(index_expr.span,
@ -1227,7 +1225,7 @@ fn trans_def_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
match def {
def::DefVariant(tid, vid, _) => {
let variant_info = ty::enum_variant_with_id(bcx.tcx(), tid, vid);
let variant_info = bcx.tcx().enum_variant_with_id(tid, vid);
if !variant_info.args.is_empty() {
// N-ary variant.
let llfn = callee::trans_fn_ref(bcx.ccx(), vid,
@ -1247,7 +1245,7 @@ fn trans_def_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
def::DefStruct(_) => {
let ty = expr_ty(bcx, ref_expr);
match ty.sty {
ty::TyStruct(did, _) if ty::has_dtor(bcx.tcx(), did) => {
ty::TyStruct(did, _) if bcx.tcx().has_dtor(did) => {
let repr = adt::represent_type(bcx.ccx(), ty);
adt::trans_set_discr(bcx, &*repr, lldest, 0);
}
@ -1342,13 +1340,22 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>,
{
match ty.sty {
ty::TyStruct(did, substs) => {
let fields = struct_fields(tcx, did, substs);
let fields = tcx.struct_fields(did, substs);
let fields = monomorphize::normalize_associated_type(tcx, &fields);
op(0, &fields[..])
}
ty::TyTuple(ref v) => {
op(0, &tup_fields(&v[..]))
let fields: Vec<_> = v.iter().enumerate().map(|(i, &f)| {
ty::field {
name: token::intern(&i.to_string()),
mt: ty::mt {
ty: f,
mutbl: ast::MutImmutable
}
}
}).collect();
op(0, &fields)
}
ty::TyEnum(_, substs) => {
@ -1364,8 +1371,8 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>,
let def = tcx.def_map.borrow().get(&node_id).unwrap().full_def();
match def {
def::DefVariant(enum_id, variant_id, _) => {
let variant_info = ty::enum_variant_with_id(tcx, enum_id, variant_id);
let fields = struct_fields(tcx, variant_id, substs);
let variant_info = tcx.enum_variant_with_id(enum_id, variant_id);
let fields = tcx.struct_fields(variant_id, substs);
let fields = monomorphize::normalize_associated_type(tcx, &fields);
op(variant_info.disr_val, &fields[..])
}
@ -2241,8 +2248,7 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
};
let ref_ty = // invoked methods have their LB regions instantiated
ty::no_late_bound_regions(
ccx.tcx(), &method_ty.fn_ret()).unwrap().unwrap();
ccx.tcx().no_late_bound_regions(&method_ty.fn_ret()).unwrap().unwrap();
let scratch = rvalue_scratch_datum(bcx, ref_ty, "overloaded_deref");
unpack_result!(bcx, trans_overloaded_op(bcx, expr, method_call,
@ -2629,9 +2635,9 @@ fn expr_kind(tcx: &ty::ctxt, expr: &ast::Expr) -> ExprKind {
match expr.node {
ast::ExprPath(..) => {
match ty::resolve_expr(tcx, expr) {
match tcx.resolve_expr(expr) {
def::DefStruct(_) | def::DefVariant(..) => {
if let ty::TyBareFn(..) = ty::node_id_to_type(tcx, expr.id).sty {
if let ty::TyBareFn(..) = tcx.node_id_to_type(expr.id).sty {
// ctor function
ExprKind::RvalueDatum
} else {

View file

@ -109,7 +109,7 @@ pub fn llvm_calling_convention(ccx: &CrateContext,
pub fn register_static(ccx: &CrateContext,
foreign_item: &ast::ForeignItem) -> ValueRef {
let ty = ty::node_id_to_type(ccx.tcx(), foreign_item.id);
let ty = ccx.tcx().node_id_to_type(foreign_item.id);
let llty = type_of::type_of(ccx, ty);
let ident = link_name(foreign_item);
@ -245,7 +245,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
ty::TyBareFn(_, ref fn_ty) => (fn_ty.abi, &fn_ty.sig),
_ => ccx.sess().bug("trans_native_call called on non-function type")
};
let fn_sig = ty::erase_late_bound_regions(ccx.tcx(), fn_sig);
let fn_sig = ccx.tcx().erase_late_bound_regions(fn_sig);
let llsig = foreign_signature(ccx, &fn_sig, &passed_arg_tys[..]);
let fn_type = cabi::compute_abi_info(ccx,
&llsig.llarg_tys,
@ -478,7 +478,7 @@ pub fn trans_foreign_mod(ccx: &CrateContext, foreign_mod: &ast::ForeignMod) {
match foreign_mod.abi {
Rust | RustIntrinsic => {}
abi => {
let ty = ty::node_id_to_type(ccx.tcx(), foreign_item.id);
let ty = ccx.tcx().node_id_to_type(foreign_item.id);
match ty.sty {
ty::TyBareFn(_, bft) => gate_simd_ffi(ccx.tcx(), &**decl, bft),
_ => ccx.tcx().sess.span_bug(foreign_item.span,
@ -554,7 +554,7 @@ pub fn register_rust_fn_with_foreign_abi(ccx: &CrateContext,
let tys = foreign_types_for_id(ccx, node_id);
let llfn_ty = lltype_for_fn_from_foreign_types(ccx, &tys);
let t = ty::node_id_to_type(ccx.tcx(), node_id);
let t = ccx.tcx().node_id_to_type(node_id);
let cconv = match t.sty {
ty::TyBareFn(_, ref fn_ty) => {
llvm_calling_convention(ccx, fn_ty.abi)
@ -578,7 +578,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
hash: Option<&str>) {
let _icx = push_ctxt("foreign::build_foreign_fn");
let fnty = ty::node_id_to_type(ccx.tcx(), id);
let fnty = ccx.tcx().node_id_to_type(id);
let mty = monomorphize::apply_param_substs(ccx.tcx(), param_substs, &fnty);
let tys = foreign_types_for_fn_ty(ccx, mty);
@ -601,7 +601,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
{
let _icx = push_ctxt("foreign::foreign::build_rust_fn");
let tcx = ccx.tcx();
let t = ty::node_id_to_type(tcx, id);
let t = tcx.node_id_to_type(id);
let t = monomorphize::apply_param_substs(tcx, param_substs, &t);
let ps = ccx.tcx().map.with_path(id, |path| {
@ -933,7 +933,7 @@ fn foreign_signature<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn foreign_types_for_id<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
id: ast::NodeId) -> ForeignTypes<'tcx> {
foreign_types_for_fn_ty(ccx, ty::node_id_to_type(ccx.tcx(), id))
foreign_types_for_fn_ty(ccx, ccx.tcx().node_id_to_type(id))
}
fn foreign_types_for_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
@ -942,7 +942,7 @@ fn foreign_types_for_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
ty::TyBareFn(_, ref fn_ty) => &fn_ty.sig,
_ => ccx.sess().bug("foreign_types_for_fn_ty called on non-function type")
};
let fn_sig = ty::erase_late_bound_regions(ccx.tcx(), fn_sig);
let fn_sig = ccx.tcx().erase_late_bound_regions(fn_sig);
let llsig = foreign_signature(ccx, &fn_sig, &fn_sig.inputs);
let fn_ty = cabi::compute_abi_info(ccx,
&llsig.llarg_tys,

View file

@ -326,7 +326,7 @@ pub fn get_res_dtor<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
} else {
let tcx = ccx.tcx();
let name = csearch::get_symbol(&ccx.sess().cstore, did);
let class_ty = ty::lookup_item_type(tcx, parent_id).ty.subst(tcx, substs);
let class_ty = tcx.lookup_item_type(parent_id).ty.subst(tcx, substs);
let llty = type_of_dtor(ccx, class_ty);
let dtor_ty = ccx.tcx().mk_ctor_fn(did,
&[get_drop_glue_type(ccx, t)],
@ -399,7 +399,7 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, in
// Recurse to get the size of the dynamically sized field (must be
// the last field).
let fields = ty::struct_fields(bcx.tcx(), id, substs);
let fields = bcx.tcx().struct_fields(id, substs);
let last_field = fields[fields.len()-1];
let field_ty = last_field.mt.ty;
let (unsized_size, unsized_align) = size_and_align_of_dst(bcx, field_ty, info);
@ -495,7 +495,7 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, g: DropGlueK
}
ty::TyStruct(did, substs) | ty::TyEnum(did, substs) => {
let tcx = bcx.tcx();
match (ty::ty_dtor(tcx, did), skip_dtor) {
match (tcx.ty_dtor(did), skip_dtor) {
(ty::TraitDtor(dtor, true), false) => {
// FIXME(16758) Since the struct is unsized, it is hard to
// find the drop flag (which is at the end of the struct).

View file

@ -14,7 +14,6 @@ use middle::astencode;
use middle::subst::Substs;
use trans::base::{push_ctxt, trans_item, get_item_val, trans_fn};
use trans::common::*;
use middle::ty;
use syntax::ast;
use syntax::ast_util::local_def;
@ -28,7 +27,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId)
Some(&Some(node_id)) => {
// Already inline
debug!("instantiate_inline({}): already inline as node id {}",
ty::item_path_str(ccx.tcx(), fn_id), node_id);
ccx.tcx().item_path_str(fn_id), node_id);
return Some(local_def(node_id));
}
Some(&None) => {
@ -104,8 +103,8 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId)
let mut my_id = 0;
match item.node {
ast::ItemEnum(_, _) => {
let vs_here = ty::enum_variants(ccx.tcx(), local_def(item.id));
let vs_there = ty::enum_variants(ccx.tcx(), parent_id);
let vs_here = ccx.tcx().enum_variants(local_def(item.id));
let vs_there = ccx.tcx().enum_variants(parent_id);
for (here, there) in vs_here.iter().zip(vs_there.iter()) {
if there.id == fn_id { my_id = here.id.node; }
ccx.external().borrow_mut().insert(there.id, Some(here.id.node));
@ -140,7 +139,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId)
// the logic to do that already exists in `middle`. In order to
// reuse that code, it needs to be able to look up the traits for
// inlined items.
let ty_trait_item = ty::impl_or_trait_item(ccx.tcx(), fn_id).clone();
let ty_trait_item = ccx.tcx().impl_or_trait_item(fn_id).clone();
ccx.tcx().impl_or_trait_items.borrow_mut()
.insert(local_def(trait_item.id), ty_trait_item);
@ -157,7 +156,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId)
// Translate monomorphic impl methods immediately.
if let ast::MethodImplItem(ref sig, ref body) = impl_item.node {
let impl_tpt = ty::lookup_item_type(ccx.tcx(), impl_did);
let impl_tpt = ccx.tcx().lookup_item_type(impl_did);
if impl_tpt.generics.types.is_empty() &&
sig.generics.ty_params.is_empty() {
let empty_substs = ccx.tcx().mk_substs(Substs::trans_empty());

View file

@ -163,7 +163,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
let ret_ty = match callee_ty.sty {
ty::TyBareFn(_, ref f) => {
ty::erase_late_bound_regions(bcx.tcx(), &f.sig.output())
bcx.tcx().erase_late_bound_regions(&f.sig.output())
}
_ => panic!("expected bare_fn in trans_intrinsic_call")
};
@ -411,10 +411,8 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
C_str_slice(ccx, ty_name)
}
(_, "type_id") => {
let hash = ty::hash_crate_independent(
ccx.tcx(),
*substs.types.get(FnSpace, 0),
&ccx.link_meta().crate_hash);
let hash = ccx.tcx().hash_crate_independent(*substs.types.get(FnSpace, 0),
&ccx.link_meta().crate_hash);
C_u64(ccx, hash)
}
(_, "init_dropped") => {

View file

@ -182,7 +182,7 @@ pub fn trans_static_method_callee<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
debug!("trans_static_method_callee(method_id={:?}, trait_id={}, \
expr_id={})",
method_id,
ty::item_path_str(tcx, trait_id),
tcx.item_path_str(trait_id),
expr_id);
let mname = if method_id.krate == ast::LOCAL_CRATE {
@ -282,7 +282,7 @@ pub fn trans_static_method_callee<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
traits::VtableObject(ref data) => {
let trait_item_def_ids =
ty::trait_item_def_ids(ccx.tcx(), trait_id);
ccx.tcx().trait_item_def_ids(trait_id);
let method_offset_in_trait =
trait_item_def_ids.iter()
.position(|item| item.def_id() == method_id)
@ -314,7 +314,7 @@ fn method_with_name(ccx: &CrateContext, impl_id: ast::DefId, name: ast::Name)
.expect("could not find impl while translating");
let meth_did = impl_items.iter()
.find(|&did| {
ty::impl_or_trait_item(ccx.tcx(), did.def_id()).name() == name
ccx.tcx().impl_or_trait_item(did.def_id()).name() == name
}).expect("could not find method while \
translating");
@ -334,7 +334,7 @@ fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
traits::VtableImpl(vtable_impl) => {
let ccx = bcx.ccx();
let impl_did = vtable_impl.impl_def_id;
let mname = match ty::trait_item(ccx.tcx(), trait_id, n_method) {
let mname = match ccx.tcx().trait_item(trait_id, n_method) {
ty::MethodTraitItem(method) => method.name,
_ => {
bcx.tcx().sess.bug("can't monomorphize a non-method trait \
@ -567,12 +567,12 @@ pub fn trans_object_shim<'a, 'tcx>(
};
// Upcast to the trait in question and extract out the substitutions.
let upcast_trait_ref = ty::erase_late_bound_regions(tcx, &upcast_trait_ref);
let upcast_trait_ref = tcx.erase_late_bound_regions(&upcast_trait_ref);
let object_substs = upcast_trait_ref.substs.clone().erase_regions();
debug!("trans_object_shim: object_substs={:?}", object_substs);
// Lookup the type of this method as declared in the trait and apply substitutions.
let method_ty = match ty::trait_item(tcx, trait_id, method_offset_in_trait) {
let method_ty = match tcx.trait_item(trait_id, method_offset_in_trait) {
ty::MethodTraitItem(method) => method,
_ => {
tcx.sess.bug("can't create a method shim for a non-method item")
@ -591,7 +591,7 @@ pub fn trans_object_shim<'a, 'tcx>(
ccx.sess().bug(&format!("symbol `{}` already defined", function_name));
});
let sig = ty::erase_late_bound_regions(ccx.tcx(), &fty.sig);
let sig = ccx.tcx().erase_late_bound_regions(&fty.sig);
let empty_substs = tcx.mk_substs(Substs::trans_empty());
let (block_arena, fcx): (TypedArena<_>, FunctionContext);
@ -747,16 +747,16 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
substs,
param_substs);
let trt_id = match ty::impl_trait_ref(tcx, impl_id) {
let trt_id = match tcx.impl_trait_ref(impl_id) {
Some(t_id) => t_id.def_id,
None => ccx.sess().bug("make_impl_vtable: don't know how to \
make a vtable for a type impl!")
};
ty::populate_implementations_for_trait_if_necessary(tcx, trt_id);
tcx.populate_implementations_for_trait_if_necessary(trt_id);
let nullptr = C_null(Type::nil(ccx).ptr_to());
let trait_item_def_ids = ty::trait_item_def_ids(tcx, trt_id);
let trait_item_def_ids = tcx.trait_item_def_ids(trt_id);
trait_item_def_ids
.iter()
@ -775,7 +775,7 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
debug!("emit_vtable_methods: trait_method_def_id={:?}",
trait_method_def_id);
let trait_method_type = match ty::impl_or_trait_item(tcx, trait_method_def_id) {
let trait_method_type = match tcx.impl_or_trait_item(trait_method_def_id) {
ty::MethodTraitItem(m) => m,
_ => ccx.sess().bug("should be a method, not other assoc item"),
};
@ -793,7 +793,7 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
// The substitutions we have are on the impl, so we grab
// the method type from the impl to substitute into.
let impl_method_def_id = method_with_name(ccx, impl_id, name);
let impl_method_type = match ty::impl_or_trait_item(tcx, impl_method_def_id) {
let impl_method_type = match tcx.impl_or_trait_item(impl_method_def_id) {
ty::MethodTraitItem(m) => m,
_ => ccx.sess().bug("should be a method, not other assoc item"),
};
@ -806,7 +806,7 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
// particular set of type parameters. Note that this
// method could then never be called, so we do not want to
// try and trans it, in that case. Issue #23435.
if ty::provided_source(tcx, impl_method_def_id).is_some() {
if tcx.provided_source(impl_method_def_id).is_some() {
let predicates = impl_method_type.predicates.predicates.subst(tcx, &substs);
if !normalize_and_test_predicates(ccx, predicates.into_vec()) {
debug!("emit_vtable_methods: predicates do not hold");

View file

@ -56,7 +56,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
params: &psubsts.types
};
let item_ty = ty::lookup_item_type(ccx.tcx(), fn_id).ty;
let item_ty = ccx.tcx().lookup_item_type(fn_id).ty;
debug!("monomorphic_fn about to subst into {:?}", item_ty);
let mono_ty = item_ty.subst(ccx.tcx(), psubsts);
@ -64,7 +64,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
match ccx.monomorphized().borrow().get(&hash_id) {
Some(&val) => {
debug!("leaving monomorphic fn {}",
ty::item_path_str(ccx.tcx(), fn_id));
ccx.tcx().item_path_str(fn_id));
return (val, mono_ty, false);
}
None => ()
@ -198,7 +198,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
ast_map::NodeVariant(v) => {
let parent = ccx.tcx().map.get_parent(fn_id.node);
let tvs = ty::enum_variants(ccx.tcx(), local_def(parent));
let tvs = ccx.tcx().enum_variants(local_def(parent));
let this_tv = tvs.iter().find(|tv| { tv.id.node == fn_id.node}).unwrap();
let d = mk_lldecl(abi::Rust);
attributes::inline(d, attributes::InlineAttr::Hint);
@ -284,7 +284,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
ccx.monomorphizing().borrow_mut().insert(fn_id, depth);
debug!("leaving monomorphic fn {}", ty::item_path_str(ccx.tcx(), fn_id));
debug!("leaving monomorphic fn {}", ccx.tcx().item_path_str(fn_id));
(lldecl, mono_ty, true)
}

View file

@ -225,7 +225,7 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
return expr::trans_into(bcx, &**element, Ignore);
}
SaveIn(lldest) => {
match ty::eval_repeat_count(bcx.tcx(), &**count_expr) {
match bcx.tcx().eval_repeat_count(&**count_expr) {
0 => expr::trans_into(bcx, &**element, Ignore),
1 => expr::trans_into(bcx, &**element, SaveIn(lldest)),
count => {
@ -277,7 +277,7 @@ fn elements_required(bcx: Block, content_expr: &ast::Expr) -> usize {
},
ast::ExprVec(ref es) => es.len(),
ast::ExprRepeat(_, ref count_expr) => {
ty::eval_repeat_count(bcx.tcx(), &**count_expr)
bcx.tcx().eval_repeat_count(&**count_expr)
}
_ => bcx.tcx().sess.span_bug(content_expr.span,
"unexpected vec content")

View file

@ -102,7 +102,7 @@ pub fn type_of_rust_fn<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
sig,
abi);
let sig = ty::erase_late_bound_regions(cx.tcx(), sig);
let sig = cx.tcx().erase_late_bound_regions(sig);
assert!(!sig.variadic); // rust fns are never variadic
let mut atys: Vec<Type> = Vec::new();
@ -362,7 +362,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
cx.tn().find_type("str_slice").unwrap()
} else {
let ptr_ty = in_memory_type_of(cx, ty).ptr_to();
let unsized_part = ty::struct_tail(cx.tcx(), ty);
let unsized_part = cx.tcx().struct_tail(ty);
let info_ty = match unsized_part.sty {
ty::TyStr | ty::TyArray(..) | ty::TySlice(_) => {
Type::uint_from_ty(cx, ast::TyUs)
@ -454,7 +454,7 @@ fn llvm_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
did: ast::DefId,
tps: &[Ty<'tcx>])
-> String {
let base = ty::item_path_str(cx.tcx(), did);
let base = cx.tcx().item_path_str(did);
let strings: Vec<String> = tps.iter().map(|t| t.to_string()).collect();
let tstr = if strings.is_empty() {
base

View file

@ -124,7 +124,7 @@ pub trait AstConv<'tcx> {
item_name: ast::Name)
-> Ty<'tcx>
{
if ty::binds_late_bound_regions(self.tcx(), &poly_trait_ref) {
if self.tcx().binds_late_bound_regions(&poly_trait_ref) {
span_err!(self.tcx().sess, span, E0212,
"cannot extract an associated type from a higher-ranked trait bound \
in this context");
@ -513,7 +513,7 @@ fn find_implied_output_region(input_tys: &[Ty], input_pats: Vec<String>)
for (input_type, input_pat) in input_tys.iter().zip(input_pats) {
let mut accumulator = Vec::new();
ty::accumulate_lifetimes_in_type(&mut accumulator, *input_type);
input_type.accumulate_lifetimes_in_type(&mut accumulator);
if accumulator.len() == 1 {
// there's a chance that the unique lifetime of this
@ -1060,7 +1060,7 @@ fn make_object_type<'tcx>(this: &AstConv<'tcx>,
let mut associated_types: FnvHashSet<(ast::DefId, ast::Name)> =
traits::supertraits(tcx, object_trait_ref)
.flat_map(|tr| {
let trait_def = ty::lookup_trait_def(tcx, tr.def_id());
let trait_def = tcx.lookup_trait_def(tr.def_id());
trait_def.associated_type_names
.clone()
.into_iter()
@ -1078,7 +1078,7 @@ fn make_object_type<'tcx>(this: &AstConv<'tcx>,
span_err!(tcx.sess, span, E0191,
"the value of the associated type `{}` (from the trait `{}`) must be specified",
name,
ty::item_path_str(tcx, trait_def_id));
tcx.item_path_str(trait_def_id));
}
tcx.mk_trait(object.principal, object.bounds)
@ -1265,7 +1265,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
_ => unreachable!()
}
} else {
let trait_items = ty::trait_items(tcx, trait_did);
let trait_items = tcx.trait_items(trait_did);
let item = trait_items.iter().find(|i| i.name() == assoc_name);
item.expect("missing associated type").def_id()
};
@ -1290,7 +1290,7 @@ fn qpath_to_ty<'tcx>(this: &AstConv<'tcx>,
let self_ty = if let Some(ty) = opt_self_ty {
ty
} else {
let path_str = ty::item_path_str(tcx, trait_def_id);
let path_str = tcx.item_path_str(trait_def_id);
report_ambiguous_associated_type(tcx,
span,
"Type",
@ -2116,8 +2116,7 @@ pub fn partition_bounds<'a>(tcx: &ty::ctxt,
ast::TraitTyParamBound(ref b, ast::TraitBoundModifier::None) => {
match ::lookup_full_def(tcx, b.trait_ref.path.span, b.trait_ref.ref_id) {
def::DefTrait(trait_did) => {
if ty::try_add_builtin_trait(tcx,
trait_did,
if tcx.try_add_builtin_trait(trait_did,
&mut builtin_bounds) {
let segments = &b.trait_ref.path.segments;
let parameters = &segments[segments.len() - 1].parameters;

View file

@ -147,7 +147,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
}
ast::PatEnum(..) | ast::PatIdent(..) if pat_is_resolved_const(&tcx.def_map, pat) => {
let const_did = tcx.def_map.borrow().get(&pat.id).unwrap().def_id();
let const_scheme = ty::lookup_item_type(tcx, const_did);
let const_scheme = tcx.lookup_item_type(const_did);
assert!(const_scheme.generics.is_empty());
let const_ty = pcx.fcx.instantiate_type_scheme(pat.span,
&Substs::empty(),
@ -227,8 +227,8 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
resolve_ty_and_def_ufcs(fcx, path_res, Some(self_ty),
path, pat.span, pat.id) {
if check_assoc_item_is_const(pcx, def, pat.span) {
let scheme = ty::lookup_item_type(tcx, def.def_id());
let predicates = ty::lookup_predicates(tcx, def.def_id());
let scheme = tcx.lookup_item_type(def.def_id());
let predicates = tcx.lookup_predicates(def.def_id());
instantiate_path(fcx, segments,
scheme, &predicates,
opt_ty, def, pat.span, pat.id);
@ -555,7 +555,7 @@ pub fn check_pat_struct<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &'tcx ast::Pat,
return;
},
_ => {
let def_type = ty::lookup_item_type(tcx, def.def_id());
let def_type = tcx.lookup_item_type(def.def_id());
match def_type.ty.sty {
ty::TyStruct(struct_def_id, _) =>
(struct_def_id, struct_def_id),
@ -579,8 +579,8 @@ pub fn check_pat_struct<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &'tcx ast::Pat,
instantiate_path(pcx.fcx,
&path.segments,
ty::lookup_item_type(tcx, enum_def_id),
&ty::lookup_predicates(tcx, enum_def_id),
tcx.lookup_item_type(enum_def_id),
&tcx.lookup_predicates(enum_def_id),
None,
def,
pat.span,
@ -595,7 +595,7 @@ pub fn check_pat_struct<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &'tcx ast::Pat,
.map(|substs| substs.substs.clone())
.unwrap_or_else(|| Substs::empty());
let struct_fields = ty::struct_fields(tcx, variant_def_id, &item_substs);
let struct_fields = tcx.struct_fields(variant_def_id, &item_substs);
check_struct_pat_fields(pcx, pat.span, fields, &struct_fields,
variant_def_id, etc);
}
@ -631,10 +631,10 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
let enum_def = def.variant_def_ids()
.map_or_else(|| def.def_id(), |(enum_def, _)| enum_def);
let ctor_scheme = ty::lookup_item_type(tcx, enum_def);
let ctor_predicates = ty::lookup_predicates(tcx, enum_def);
let ctor_scheme = tcx.lookup_item_type(enum_def);
let ctor_predicates = tcx.lookup_predicates(enum_def);
let path_scheme = if ctor_scheme.ty.is_fn() {
let fn_ret = ty::no_late_bound_regions(tcx, &ctor_scheme.ty.fn_ret()).unwrap();
let fn_ret = tcx.no_late_bound_regions(&ctor_scheme.ty.fn_ret()).unwrap();
ty::TypeScheme {
ty: fn_ret.unwrap(),
generics: ctor_scheme.generics,
@ -664,14 +664,14 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
ty::TyEnum(enum_def_id, expected_substs)
if def == def::DefVariant(enum_def_id, def.def_id(), false) =>
{
let variant = ty::enum_variant_with_id(tcx, enum_def_id, def.def_id());
let variant = tcx.enum_variant_with_id(enum_def_id, def.def_id());
(variant.args.iter()
.map(|t| fcx.instantiate_type_scheme(pat.span, expected_substs, t))
.collect(),
"variant")
}
ty::TyStruct(struct_def_id, expected_substs) => {
let struct_fields = ty::struct_fields(tcx, struct_def_id, expected_substs);
let struct_fields = tcx.struct_fields(struct_def_id, expected_substs);
(struct_fields.iter()
.map(|field| fcx.instantiate_type_scheme(pat.span,
expected_substs,
@ -761,7 +761,7 @@ pub fn check_struct_pat_fields<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
.unwrap_or_else(|| {
span_err!(tcx.sess, span, E0026,
"struct `{}` does not have a field named `{}`",
ty::item_path_str(tcx, struct_id),
tcx.item_path_str(struct_id),
token::get_ident(field.ident));
tcx.types.err
})

View file

@ -358,9 +358,8 @@ impl<'tcx> DeferredCallResolution<'tcx> for CallResolution<'tcx> {
// can't because of the annoying need for a TypeTrace.
// (This always bites me, should find a way to
// refactor it.)
let method_sig =
ty::no_late_bound_regions(fcx.tcx(),
method_callee.ty.fn_sig()).unwrap();
let method_sig = fcx.tcx().no_late_bound_regions(method_callee.ty.fn_sig())
.unwrap();
debug!("attempt_resolution: method_callee={:?}",
method_callee);

View file

@ -80,7 +80,7 @@ fn unsize_kind<'a,'tcx>(fcx: &FnCtxt<'a, 'tcx>,
ty::TySlice(_) | ty::TyStr => Some(UnsizeKind::Length),
ty::TyTrait(ref tty) => Some(UnsizeKind::Vtable(tty.principal_def_id())),
ty::TyStruct(did, substs) => {
match ty::struct_fields(fcx.tcx(), did, substs).pop() {
match fcx.tcx().struct_fields(did, substs).pop() {
None => None,
Some(f) => unsize_kind(fcx, f.mt.ty)
}

View file

@ -65,10 +65,8 @@ fn check_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
fcx.write_ty(expr.id, closure_type);
let fn_sig =
ty::liberate_late_bound_regions(fcx.tcx(),
region::DestructionScopeData::new(body.id),
&fn_ty.sig);
let fn_sig = fcx.tcx().liberate_late_bound_regions(
region::DestructionScopeData::new(body.id), &fn_ty.sig);
check_fn(fcx.ccx,
ast::Unsafety::Normal,

View file

@ -271,7 +271,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
}
_ => (source, None)
};
let source = ty::adjust_ty_for_autoref(self.tcx(), source, reborrow);
let source = source.adjust_for_autoref(self.tcx(), reborrow);
let mut selcx = traits::SelectionContext::new(self.fcx.infcx(), self.fcx);

View file

@ -100,7 +100,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
token::get_name(trait_m.name),
impl_m.fty.sig.0.inputs.len(),
if impl_m.fty.sig.0.inputs.len() == 1 {""} else {"s"},
ty::item_path_str(tcx, trait_m.def_id),
tcx.item_path_str(trait_m.def_id),
trait_m.fty.sig.0.inputs.len());
return;
}

View file

@ -37,8 +37,8 @@ use syntax::codemap::{self, Span};
///
pub fn check_drop_impl(tcx: &ty::ctxt, drop_impl_did: ast::DefId) -> Result<(), ()> {
let ty::TypeScheme { generics: ref dtor_generics,
ty: dtor_self_type } = ty::lookup_item_type(tcx, drop_impl_did);
let dtor_predicates = ty::lookup_predicates(tcx, drop_impl_did);
ty: dtor_self_type } = tcx.lookup_item_type(drop_impl_did);
let dtor_predicates = tcx.lookup_predicates(drop_impl_did);
match dtor_self_type.sty {
ty::TyEnum(self_type_did, self_to_impl_substs) |
ty::TyStruct(self_type_did, self_to_impl_substs) |
@ -91,7 +91,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
let ty::TypeScheme { generics: ref named_type_generics,
ty: named_type } =
ty::lookup_item_type(tcx, self_type_did);
tcx.lookup_item_type(self_type_did);
let infcx = infer::new_infer_ctxt(tcx);
infcx.commit_if_ok(|snapshot| {
@ -179,7 +179,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
// We can assume the predicates attached to struct/enum definition
// hold.
let generic_assumptions = ty::lookup_predicates(tcx, self_type_did);
let generic_assumptions = tcx.lookup_predicates(self_type_did);
let assumptions_in_impl_context = generic_assumptions.instantiate(tcx, &self_to_impl_substs);
assert!(assumptions_in_impl_context.predicates.is_empty_in(subst::SelfSpace));
@ -288,7 +288,7 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>
rcx.tcx().sess,
span,
"overflowed on enum {} variant {} argument {} type: {}",
ty::item_path_str(tcx, def_id),
tcx.item_path_str(def_id),
variant,
arg_index,
detected_on_typ);
@ -298,7 +298,7 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>
rcx.tcx().sess,
span,
"overflowed on struct {} field {} type: {}",
ty::item_path_str(tcx, def_id),
tcx.item_path_str(def_id),
field,
detected_on_typ);
}
@ -365,7 +365,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>(
let (typ, xref_depth) = match typ.sty {
ty::TyStruct(struct_did, substs) => {
if opt_phantom_data_def_id == Some(struct_did) {
let item_type = ty::lookup_item_type(rcx.tcx(), struct_did);
let item_type = rcx.tcx().lookup_item_type(struct_did);
let tp_def = item_type.generics.types
.opt_get(subst::TypeSpace, 0).unwrap();
let new_typ = substs.type_for_def(tp_def);
@ -471,13 +471,11 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>(
walker.skip_current_subtree();
let fields =
ty::lookup_struct_fields(rcx.tcx(), struct_did);
rcx.tcx().lookup_struct_fields(struct_did);
for field in &fields {
let field_type =
ty::lookup_field_type(rcx.tcx(),
struct_did,
field.id,
substs);
let field_type = rcx.tcx().lookup_field_type(struct_did,
field.id,
substs);
try!(iterate_over_potentially_unsafe_regions_in_type(
rcx,
breadcrumbs,
@ -501,9 +499,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>(
walker.skip_current_subtree();
let all_variant_info =
ty::substd_enum_variants(rcx.tcx(),
enum_did,
substs);
rcx.tcx().substd_enum_variants(enum_did, substs);
for variant_info in &all_variant_info {
for (i, arg_type) in variant_info.args.iter().enumerate() {
try!(iterate_over_potentially_unsafe_regions_in_type(
@ -591,13 +587,13 @@ fn has_dtor_of_interest<'tcx>(tcx: &ty::ctxt<'tcx>,
}
}
DtorKind::KnownDropMethod(dtor_method_did) => {
let impl_did = ty::impl_of_method(tcx, dtor_method_did)
let impl_did = tcx.impl_of_method(dtor_method_did)
.unwrap_or_else(|| {
tcx.sess.span_bug(
span, "no Drop impl found for drop method")
});
let dtor_typescheme = ty::lookup_item_type(tcx, impl_did);
let dtor_typescheme = tcx.lookup_item_type(impl_did);
let dtor_generics = dtor_typescheme.generics;
let mut has_pred_of_interest = false;
@ -609,7 +605,7 @@ fn has_dtor_of_interest<'tcx>(tcx: &ty::ctxt<'tcx>,
continue;
}
for pred in ty::lookup_predicates(tcx, item_def_id).predicates {
for pred in tcx.lookup_predicates(item_def_id).predicates {
let result = match pred {
ty::Predicate::Equate(..) |
ty::Predicate::RegionOutlives(..) |
@ -623,7 +619,7 @@ fn has_dtor_of_interest<'tcx>(tcx: &ty::ctxt<'tcx>,
ty::Predicate::Trait(ty::Binder(ref t_pred)) => {
let def_id = t_pred.trait_ref.def_id;
if ty::trait_items(tcx, def_id).len() != 0 {
if tcx.trait_items(def_id).len() != 0 {
// If trait has items, assume it adds
// capability to access borrowed data.
true

View file

@ -139,7 +139,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
let region = self.infcx().next_region_var(infer::Autoref(self.span));
let autoref = ty::AutoPtr(self.tcx().mk_region(region), mutbl);
(Some(autoref), pick.unsize.map(|target| {
ty::adjust_ty_for_autoref(self.tcx(), target, Some(autoref))
target.adjust_for_autoref(self.tcx(), Some(autoref))
}))
} else {
// No unsizing should be performed without autoref (at
@ -179,7 +179,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
if let Some(target) = unsize {
target
} else {
ty::adjust_ty_for_autoref(self.tcx(), autoderefd_ty, autoref)
autoderefd_ty.adjust_for_autoref(self.tcx(), autoref)
}
}
@ -199,7 +199,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
{
match pick.kind {
probe::InherentImplPick(impl_def_id) => {
assert!(ty::impl_trait_ref(self.tcx(), impl_def_id).is_none(),
assert!(self.tcx().impl_trait_ref(impl_def_id).is_none(),
"impl {:?} is not an inherent impl", impl_def_id);
let impl_polytype = check::impl_self_ty(self.fcx, self.span, impl_def_id);
@ -254,7 +254,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
self.fcx.instantiate_type_scheme(
self.span,
&impl_polytype.substs,
&ty::impl_trait_ref(self.tcx(), impl_def_id).unwrap());
&self.tcx().impl_trait_ref(impl_def_id).unwrap());
let origin = MethodTypeParam(MethodParam { trait_ref: impl_trait_ref.clone(),
method_num: method_num,
impl_def_id: Some(impl_def_id) });
@ -262,7 +262,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
}
probe::TraitPick(trait_def_id, method_num) => {
let trait_def = ty::lookup_trait_def(self.tcx(), trait_def_id);
let trait_def = self.tcx().lookup_trait_def(trait_def_id);
// Make a trait reference `$0 : Trait<$1...$n>`
// consisting entirely of type variables. Later on in

View file

@ -167,7 +167,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
m_name,
trait_def_id);
let trait_def = ty::lookup_trait_def(fcx.tcx(), trait_def_id);
let trait_def = fcx.tcx().lookup_trait_def(trait_def_id);
let expected_number_of_input_types = trait_def.generics.types.len(subst::TypeSpace);
let input_types = match opt_input_types {
@ -359,7 +359,7 @@ fn trait_item<'tcx>(tcx: &ty::ctxt<'tcx>,
item_name: ast::Name)
-> Option<(usize, ty::ImplOrTraitItem<'tcx>)>
{
let trait_items = ty::trait_items(tcx, trait_def_id);
let trait_items = tcx.trait_items(trait_def_id);
trait_items
.iter()
.enumerate()
@ -376,6 +376,6 @@ fn impl_item<'tcx>(tcx: &ty::ctxt<'tcx>,
let impl_items = impl_items.get(&impl_def_id).unwrap();
impl_items
.iter()
.map(|&did| ty::impl_or_trait_item(tcx, did.def_id()))
.map(|&did| tcx.impl_or_trait_item(did.def_id()))
.find(|m| m.name() == item_name)
}

View file

@ -377,7 +377,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
fn assemble_inherent_impl_for_primitive(&mut self, lang_def_id: Option<ast::DefId>) {
if let Some(impl_def_id) = lang_def_id {
ty::populate_implementations_for_primitive_if_necessary(self.tcx(), impl_def_id);
self.tcx().populate_implementations_for_primitive_if_necessary(impl_def_id);
self.assemble_inherent_impl_probe(impl_def_id);
}
@ -386,7 +386,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
fn assemble_inherent_impl_candidates_for_type(&mut self, def_id: ast::DefId) {
// Read the inherent implementation candidates for this type from the
// metadata if necessary.
ty::populate_inherent_implementations_for_type_if_necessary(self.tcx(), def_id);
self.tcx().populate_inherent_implementations_for_type_if_necessary(def_id);
if let Some(impl_infos) = self.tcx().inherent_impls.borrow().get(&def_id) {
for &impl_def_id in impl_infos.iter() {
@ -606,7 +606,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
// Check whether `trait_def_id` defines a method with suitable name:
let trait_items =
ty::trait_items(self.tcx(), trait_def_id);
self.tcx().trait_items(trait_def_id);
let matching_index =
trait_items.iter()
.position(|item| item.name() == self.item_name);
@ -647,7 +647,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
item: ty::ImplOrTraitItem<'tcx>,
item_index: usize)
{
let trait_def = ty::lookup_trait_def(self.tcx(), trait_def_id);
let trait_def = self.tcx().lookup_trait_def(trait_def_id);
// FIXME(arielb1): can we use for_each_relevant_impl here?
trait_def.for_each_impl(self.tcx(), |impl_def_id| {
@ -665,7 +665,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
debug!("impl_substs={:?}", impl_substs);
let impl_trait_ref =
ty::impl_trait_ref(self.tcx(), impl_def_id)
self.tcx().impl_trait_ref(impl_def_id)
.unwrap() // we know this is a trait impl
.subst(self.tcx(), &impl_substs);
@ -705,7 +705,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
None => { return true; }
};
let impl_type = ty::lookup_item_type(self.tcx(), impl_def_id);
let impl_type = self.tcx().lookup_item_type(impl_def_id);
let impl_simplified_type =
match fast_reject::simplify_type(self.tcx(), impl_type.ty, false) {
Some(simplified_type) => simplified_type,
@ -759,7 +759,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
// for the purposes of our method lookup, we only take
// receiver type into account, so we can just substitute
// fresh types here to use during substitution and subtyping.
let trait_def = ty::lookup_trait_def(self.tcx(), trait_def_id);
let trait_def = self.tcx().lookup_trait_def(trait_def_id);
let substs = self.infcx().fresh_substs_for_trait(self.span,
&trait_def.generics,
step.self_ty);
@ -802,8 +802,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
debug!("assemble_projection_candidates: projection_trait_ref={:?}",
projection_trait_ref);
let trait_predicates = ty::lookup_predicates(self.tcx(),
projection_trait_ref.def_id);
let trait_predicates = self.tcx().lookup_predicates(projection_trait_ref.def_id);
let bounds = trait_predicates.instantiate(self.tcx(), projection_trait_ref.substs);
let predicates = bounds.predicates.into_vec();
debug!("assemble_projection_candidates: predicates={:?}",
@ -894,7 +893,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
match source {
TraitSource(id) => id,
ImplSource(impl_id) => {
match ty::trait_id_of_impl(tcx, impl_id) {
match tcx.trait_id_of_impl(impl_id) {
Some(id) => id,
None =>
tcx.sess.span_bug(span,
@ -1081,7 +1080,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
let cause = traits::ObligationCause::misc(self.span, self.fcx.body_id);
// Check whether the impl imposes obligations we have to worry about.
let impl_bounds = ty::lookup_predicates(self.tcx(), impl_def_id);
let impl_bounds = self.tcx().lookup_predicates(impl_def_id);
let impl_bounds = impl_bounds.instantiate(self.tcx(), substs);
let traits::Normalized { value: impl_bounds,
obligations: norm_obligations } =
@ -1266,7 +1265,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
impl_def_id: ast::DefId)
-> (Ty<'tcx>, subst::Substs<'tcx>)
{
let impl_pty = ty::lookup_item_type(self.tcx(), impl_def_id);
let impl_pty = self.tcx().lookup_item_type(impl_def_id);
let type_vars =
impl_pty.generics.types.map(
@ -1301,7 +1300,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
fn erase_late_bound_regions<T>(&self, value: &ty::Binder<T>) -> T
where T : TypeFoldable<'tcx>
{
ty::erase_late_bound_regions(self.tcx(), value)
self.tcx().erase_late_bound_regions(value)
}
}
@ -1314,7 +1313,7 @@ fn impl_item<'tcx>(tcx: &ty::ctxt<'tcx>,
let impl_items = impl_items.get(&impl_def_id).unwrap();
impl_items
.iter()
.map(|&did| ty::impl_or_trait_item(tcx, did.def_id()))
.map(|&did| tcx.impl_or_trait_item(did.def_id()))
.find(|item| item.name() == item_name)
}
@ -1325,7 +1324,7 @@ fn trait_item<'tcx>(tcx: &ty::ctxt<'tcx>,
item_name: ast::Name)
-> Option<(usize, ty::ImplOrTraitItem<'tcx>)>
{
let trait_items = ty::trait_items(tcx, trait_def_id);
let trait_items = tcx.trait_items(trait_def_id);
debug!("trait_method; items: {:?}", trait_items);
trait_items
.iter()

View file

@ -66,7 +66,7 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// If the item has the name of a field, give a help note
if let (&ty::TyStruct(did, substs), Some(expr)) = (&rcvr_ty.sty, rcvr_expr) {
let fields = ty::lookup_struct_fields(cx, did);
let fields = cx.lookup_struct_fields(did);
if let Some(field) = fields.iter().find(|f| f.name == item_name) {
let expr_string = match cx.sess.codemap().span_to_snippet(expr.span) {
@ -89,7 +89,7 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
};
// Determine if the field can be used as a function in some way
let field_ty = ty::lookup_field_type(cx, did, field.id, substs);
let field_ty = cx.lookup_field_type(did, field.id, substs);
if let Ok(fn_once_trait_did) = cx.lang_items.require(FnOnceTraitLangItem) {
let infcx = fcx.infcx();
infcx.probe(|_| {
@ -159,7 +159,7 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
invoked on this closure as we have not yet inferred what \
kind of closure it is",
item_name,
ty::item_path_str(fcx.tcx(), trait_def_id));
fcx.tcx().item_path_str(trait_def_id));
let msg = if let Some(callee) = rcvr_expr {
format!("{}; use overloaded call notation instead (e.g., `{}()`)",
msg, pprust::expr_to_string(callee))
@ -188,11 +188,12 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
let impl_ty = check::impl_self_ty(fcx, span, impl_did).ty;
let insertion = match ty::impl_trait_ref(fcx.tcx(), impl_did) {
let insertion = match fcx.tcx().impl_trait_ref(impl_did) {
None => format!(""),
Some(trait_ref) => format!(" of the trait `{}`",
ty::item_path_str(fcx.tcx(),
trait_ref.def_id)),
Some(trait_ref) => {
format!(" of the trait `{}`",
fcx.tcx().item_path_str(trait_ref.def_id))
}
};
span_note!(fcx.sess(), item_span,
@ -207,7 +208,7 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
span_note!(fcx.sess(), item_span,
"candidate #{} is defined in the trait `{}`",
idx + 1,
ty::item_path_str(fcx.tcx(), trait_did));
fcx.tcx().item_path_str(trait_did));
}
}
}
@ -243,7 +244,7 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
fcx.sess().fileline_help(span,
&*format!("candidate #{}: use `{}`",
i + 1,
ty::item_path_str(fcx.tcx(), *trait_did)))
fcx.tcx().item_path_str(*trait_did)))
}
return
@ -289,7 +290,7 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
fcx.sess().fileline_help(span,
&*format!("candidate #{}: `{}`",
i + 1,
ty::item_path_str(fcx.tcx(), trait_info.def_id)))
fcx.tcx().item_path_str(trait_info.def_id)))
}
}
}

View file

@ -97,7 +97,6 @@ use middle::traits::{self, report_fulfillment_errors};
use middle::ty::{FnSig, GenericPredicates, TypeScheme};
use middle::ty::{Disr, ParamTy, ParameterEnvironment};
use middle::ty::{self, HasTypeFlags, RegionEscape, ToPolyTraitRef, Ty};
use middle::ty::liberate_late_bound_regions;
use middle::ty::{MethodCall, MethodCallee, MethodMap};
use middle::ty_fold::{TypeFolder, TypeFoldable};
use rscope::RegionScope;
@ -308,7 +307,7 @@ impl<'a, 'tcx> mc::Typer<'tcx> for FnCtxt<'a, 'tcx> {
let ty = self.adjust_expr_ty(expr, self.inh.adjustments.borrow().get(&expr.id));
self.resolve_type_vars_or_error(&ty)
}
fn type_moves_by_default(&self, span: Span, ty: Ty<'tcx>) -> bool {
fn type_moves_by_default(&self, ty: Ty<'tcx>, span: Span) -> bool {
let ty = self.infcx().resolve_type_vars_if_possible(&ty);
!traits::type_known_to_meet_builtin_bound(self.infcx(), self, ty, ty::BoundCopy, span)
}
@ -363,9 +362,8 @@ impl<'a, 'tcx> ty::ClosureTyper<'tcx> for FnCtxt<'a, 'tcx> {
fn closure_upvars(&self,
def_id: ast::DefId,
substs: &Substs<'tcx>)
-> Option<Vec<ty::ClosureUpvar<'tcx>>>
{
ty::closure_upvars(self, def_id, substs)
-> Option<Vec<ty::ClosureUpvar<'tcx>>> {
ty::ctxt::closure_upvars(self, def_id, substs)
}
}
@ -430,7 +428,7 @@ fn static_inherited_fields<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>)
-> Inherited<'a, 'tcx> {
// It's kind of a kludge to manufacture a fake function context
// and statement context, but we might as well do write the code only once
let param_env = ty::empty_parameter_environment(ccx.tcx);
let param_env = ccx.tcx.empty_parameter_environment();
Inherited::new(ccx.tcx, param_env)
}
@ -512,9 +510,8 @@ fn check_bare_fn<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
let fn_sig =
fn_ty.sig.subst(ccx.tcx, &inh.param_env.free_substs);
let fn_sig =
liberate_late_bound_regions(ccx.tcx,
region::DestructionScopeData::new(body.id),
&fn_sig);
ccx.tcx.liberate_late_bound_regions(region::DestructionScopeData::new(body.id),
&fn_sig);
let fn_sig =
inh.normalize_associated_types_in(&inh.param_env, body.span, body.id, &fn_sig);
@ -718,7 +715,7 @@ pub fn check_struct(ccx: &CrateCtxt, id: ast::NodeId, span: Span) {
check_representable(tcx, span, id, "struct");
check_instantiable(tcx, span, id);
if ty::lookup_simd(tcx, local_def(id)) {
if tcx.lookup_simd(local_def(id)) {
check_simd(tcx, span, id);
}
}
@ -726,7 +723,7 @@ pub fn check_struct(ccx: &CrateCtxt, id: ast::NodeId, span: Span) {
pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
debug!("check_item_type(it.id={}, it.ident={})",
it.id,
ty::item_path_str(ccx.tcx, local_def(it.id)));
ccx.tcx.item_path_str(local_def(it.id)));
let _indenter = indenter();
match it.node {
// Consts can play a role in type-checking, so they are included here.
@ -741,7 +738,7 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
ast::ItemFn(..) => {} // entirely within check_item_body
ast::ItemImpl(_, _, _, _, _, ref impl_items) => {
debug!("ItemImpl {} with id {}", token::get_ident(it.ident), it.id);
match ty::impl_trait_ref(ccx.tcx, local_def(it.id)) {
match ccx.tcx.impl_trait_ref(local_def(it.id)) {
Some(impl_trait_ref) => {
check_impl_items_against_trait(ccx,
it.span,
@ -758,7 +755,7 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
check_struct(ccx, it.id, it.span);
}
ast::ItemTy(ref t, ref generics) => {
let pty_ty = ty::node_id_to_type(ccx.tcx, it.id);
let pty_ty = ccx.tcx.node_id_to_type(it.id);
check_bounds_are_used(ccx, t.span, &generics.ty_params, pty_ty);
}
ast::ItemForeignMod(ref m) => {
@ -768,7 +765,7 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
}
} else {
for item in &m.items {
let pty = ty::lookup_item_type(ccx.tcx, local_def(item.id));
let pty = ccx.tcx.lookup_item_type(local_def(item.id));
if !pty.generics.types.is_empty() {
span_err!(ccx.tcx.sess, item.span, E0044,
"foreign items may not have type parameters");
@ -790,18 +787,18 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
pub fn check_item_body<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
debug!("check_item_body(it.id={}, it.ident={})",
it.id,
ty::item_path_str(ccx.tcx, local_def(it.id)));
ccx.tcx.item_path_str(local_def(it.id)));
let _indenter = indenter();
match it.node {
ast::ItemFn(ref decl, _, _, _, _, ref body) => {
let fn_pty = ty::lookup_item_type(ccx.tcx, ast_util::local_def(it.id));
let fn_pty = ccx.tcx.lookup_item_type(ast_util::local_def(it.id));
let param_env = ParameterEnvironment::for_item(ccx.tcx, it.id);
check_bare_fn(ccx, &**decl, &**body, it.id, it.span, fn_pty.ty, param_env);
}
ast::ItemImpl(_, _, _, _, _, ref impl_items) => {
debug!("ItemImpl {} with id {}", token::get_ident(it.ident), it.id);
let impl_pty = ty::lookup_item_type(ccx.tcx, ast_util::local_def(it.id));
let impl_pty = ccx.tcx.lookup_item_type(ast_util::local_def(it.id));
for impl_item in impl_items {
match impl_item.node {
@ -820,7 +817,7 @@ pub fn check_item_body<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
}
}
ast::ItemTrait(_, _, _, ref trait_items) => {
let trait_def = ty::lookup_trait_def(ccx.tcx, local_def(it.id));
let trait_def = ccx.tcx.lookup_trait_def(local_def(it.id));
for trait_item in trait_items {
match trait_item.node {
ast::ConstTraitItem(_, Some(ref expr)) => {
@ -921,7 +918,7 @@ fn check_method_body<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
item_generics, id);
let param_env = ParameterEnvironment::for_item(ccx.tcx, id);
let fty = ty::node_id_to_type(ccx.tcx, id);
let fty = ccx.tcx.node_id_to_type(id);
debug!("check_method_body: fty={:?}", fty);
check_bare_fn(ccx, &sig.decl, body, id, span, fty, param_env);
@ -933,7 +930,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
impl_items: &[P<ast::ImplItem>]) {
// Locate trait methods
let tcx = ccx.tcx;
let trait_items = ty::trait_items(tcx, impl_trait_ref.def_id);
let trait_items = tcx.trait_items(impl_trait_ref.def_id);
// Check existing impl methods to see if they are both present in trait
// and compatible with trait signature
@ -941,8 +938,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
match impl_item.node {
ast::ConstImplItem(..) => {
let impl_const_def_id = local_def(impl_item.id);
let impl_const_ty = ty::impl_or_trait_item(ccx.tcx,
impl_const_def_id);
let impl_const_ty = ccx.tcx.impl_or_trait_item(impl_const_def_id);
// Find associated const definition.
let opt_associated_const =
@ -985,8 +981,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
check_trait_fn_not_const(ccx, impl_item.span, sig.constness);
let impl_method_def_id = local_def(impl_item.id);
let impl_item_ty = ty::impl_or_trait_item(ccx.tcx,
impl_method_def_id);
let impl_item_ty = ccx.tcx.impl_or_trait_item(impl_method_def_id);
// If this is an impl of a trait method, find the
// corresponding method definition in the trait.
@ -1027,8 +1022,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
}
ast::TypeImplItem(_) => {
let typedef_def_id = local_def(impl_item.id);
let typedef_ty = ty::impl_or_trait_item(ccx.tcx,
typedef_def_id);
let typedef_ty = ccx.tcx.impl_or_trait_item(typedef_def_id);
// If this is an impl of an associated type, find the
// corresponding type definition in the trait.
@ -1067,8 +1061,8 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
}
// Check for missing items from trait
let provided_methods = ty::provided_trait_methods(tcx, impl_trait_ref.def_id);
let associated_consts = ty::associated_consts(tcx, impl_trait_ref.def_id);
let provided_methods = tcx.provided_trait_methods(impl_trait_ref.def_id);
let associated_consts = tcx.associated_consts(impl_trait_ref.def_id);
let mut missing_items = Vec::new();
for trait_item in trait_items.iter() {
match *trait_item {
@ -1189,13 +1183,13 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
fn get_item_type_scheme(&self, _: Span, id: ast::DefId)
-> Result<ty::TypeScheme<'tcx>, ErrorReported>
{
Ok(ty::lookup_item_type(self.tcx(), id))
Ok(self.tcx().lookup_item_type(id))
}
fn get_trait_def(&self, _: Span, id: ast::DefId)
-> Result<&'tcx ty::TraitDef<'tcx>, ErrorReported>
{
Ok(ty::lookup_trait_def(self.tcx(), id))
Ok(self.tcx().lookup_trait_def(id))
}
fn ensure_super_predicates(&self, _: Span, _: ast::DefId) -> Result<(), ErrorReported> {
@ -1238,7 +1232,7 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
assoc_name: ast::Name)
-> bool
{
let trait_def = ty::lookup_trait_def(self.ccx.tcx, trait_def_id);
let trait_def = self.ccx.tcx.lookup_trait_def(trait_def_id);
trait_def.associated_type_names.contains(&assoc_name)
}
@ -1506,9 +1500,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
-> TypeAndSubsts<'tcx>
{
let type_scheme =
ty::lookup_item_type(self.tcx(), def_id);
self.tcx().lookup_item_type(def_id);
let type_predicates =
ty::lookup_predicates(self.tcx(), def_id);
self.tcx().lookup_predicates(def_id);
let substs =
self.infcx().fresh_substs_for_generics(
span,
@ -1543,7 +1537,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let tcx = self.tcx();
let ty::TypeScheme { generics, ty: decl_ty } =
ty::lookup_item_type(tcx, did);
tcx.lookup_item_type(did);
let substs = astconv::ast_path_substs_for_ty(self, self,
path.span,
@ -1651,14 +1645,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let raw_ty = self.expr_ty(expr);
let raw_ty = self.infcx().shallow_resolve(raw_ty);
let resolve_ty = |ty: Ty<'tcx>| self.infcx().resolve_type_vars_if_possible(&ty);
ty::adjust_ty(self.tcx(),
expr.span,
expr.id,
raw_ty,
adjustment,
|method_call| self.inh.method_map.borrow()
.get(&method_call)
.map(|method| resolve_ty(method.ty)))
raw_ty.adjust(self.tcx(), expr.span, expr.id, adjustment, |method_call| {
self.inh.method_map.borrow().get(&method_call)
.map(|method| resolve_ty(method.ty))
})
}
pub fn node_ty(&self, id: ast::NodeId) -> Ty<'tcx> {
@ -1798,7 +1788,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
-> Option<Ty<'tcx>>
{
let o_field = items.iter().find(|f| f.name == fieldname);
o_field.map(|f| ty::lookup_field_type(self.tcx(), class_id, f.id, substs))
o_field.map(|f| self.tcx().lookup_field_type(class_id, f.id, substs))
.map(|t| self.normalize_associated_types_in(span, &t))
}
@ -1811,7 +1801,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
-> Option<Ty<'tcx>>
{
let o_field = if idx < items.len() { Some(&items[idx]) } else { None };
o_field.map(|f| ty::lookup_field_type(self.tcx(), class_id, f.id, substs))
o_field.map(|f| self.tcx().lookup_field_type(class_id, f.id, substs))
.map(|t| self.normalize_associated_types_in(span, &t))
}
@ -2046,7 +2036,7 @@ fn make_overloaded_lvalue_return_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// extract method method return type, which will be &T;
// all LB regions should have been instantiated during method lookup
let ret_ty = method.ty.fn_ret();
let ret_ty = ty::no_late_bound_regions(fcx.tcx(), &ret_ty).unwrap().unwrap();
let ret_ty = fcx.tcx().no_late_bound_regions(&ret_ty).unwrap().unwrap();
if let Some(method_call) = method_call {
fcx.inh.method_map.borrow_mut().insert(method_call, method);
@ -2528,7 +2518,7 @@ pub fn impl_self_ty<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
-> TypeAndSubsts<'tcx> {
let tcx = fcx.tcx();
let ity = ty::lookup_item_type(tcx, did);
let ity = tcx.lookup_item_type(did);
let (n_tps, rps, raw_ty) =
(ity.generics.types.len(subst::TypeSpace),
ity.generics.regions.get_slice(subst::TypeSpace),
@ -2738,7 +2728,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
match base_t.sty {
ty::TyStruct(base_id, substs) => {
debug!("struct named {:?}", base_t);
let fields = ty::lookup_struct_fields(tcx, base_id);
let fields = tcx.lookup_struct_fields(base_id);
fcx.lookup_field_ty(expr.span, base_id, &fields[..],
field.node.name, &(*substs))
}
@ -2794,7 +2784,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
let name = &ident;
// only find fits with at least one matching letter
let mut best_dist = name.len();
let fields = ty::lookup_struct_fields(tcx, id);
let fields = tcx.lookup_struct_fields(id);
let mut best = None;
for elem in &fields {
let n = elem.name.as_str();
@ -2839,10 +2829,10 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|base_t, _| {
match base_t.sty {
ty::TyStruct(base_id, substs) => {
tuple_like = ty::is_tuple_struct(tcx, base_id);
tuple_like = tcx.is_tuple_struct(base_id);
if tuple_like {
debug!("tuple struct named {:?}", base_t);
let fields = ty::lookup_struct_fields(tcx, base_id);
let fields = tcx.lookup_struct_fields(base_id);
fcx.lookup_tup_field_ty(expr.span, base_id, &fields[..],
idx.node, &(*substs))
} else {
@ -2915,8 +2905,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
field.ident.span,
|actual| match enum_id_opt {
Some(enum_id) => {
let variant_type = ty::enum_variant_with_id(tcx,
enum_id,
let variant_type = tcx.enum_variant_with_id(enum_id,
class_id);
format!("struct variant `{}::{}` has no field named `{}`",
actual, variant_type.name.as_str(),
@ -2934,7 +2923,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
let skip_fields = ast_fields.iter().map(|ref x| x.ident.node.name.as_str());
let actual_id = match enum_id_opt {
Some(_) => class_id,
None => ty::ty_to_def_id(struct_ty).unwrap()
None => struct_ty.ty_to_def_id().unwrap()
};
suggest_field_names(actual_id, &field.ident, tcx, skip_fields.collect());
error_happened = true;
@ -2947,8 +2936,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
}
Some((field_id, false)) => {
expected_field_type =
ty::lookup_field_type(
tcx, class_id, field_id, substitutions);
tcx.lookup_field_type(class_id, field_id, substitutions);
expected_field_type =
fcx.normalize_associated_types_in(
field.span, &expected_field_type);
@ -3008,7 +2996,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
} = fcx.instantiate_type(span, class_id);
// Look up and check the fields.
let class_fields = ty::lookup_struct_fields(tcx, class_id);
let class_fields = tcx.lookup_struct_fields(class_id);
check_struct_or_variant_fields(fcx,
struct_type,
span,
@ -3051,7 +3039,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
} = fcx.instantiate_type(span, enum_id);
// Look up and check the enum variant fields.
let variant_fields = ty::lookup_struct_fields(tcx, variant_id);
let variant_fields = tcx.lookup_struct_fields(variant_id);
check_struct_or_variant_fields(fcx,
enum_type,
span,
@ -3208,7 +3196,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
let hint = expected.only_has_type(fcx).map_or(NoExpectation, |ty| {
match ty.sty {
ty::TyRef(_, ref mt) | ty::TyRawPtr(ref mt) => {
if ty::expr_is_lval(fcx.tcx(), &**oprnd) {
if fcx.tcx().expr_is_lval(&**oprnd) {
// Lvalues may legitimately have unsized types.
// For example, dereferences of a fat pointer and
// the last field of a struct can be unsized.
@ -3336,7 +3324,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
check_expr_with_lvalue_pref(fcx, &**lhs, PreferMutLvalue);
let tcx = fcx.tcx();
if !ty::expr_is_lval(tcx, &**lhs) {
if !tcx.expr_is_lval(&**lhs) {
span_err!(tcx.sess, expr.span, E0070,
"illegal left-hand side expression");
}
@ -3465,7 +3453,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
}
ast::ExprRepeat(ref element, ref count_expr) => {
check_expr_has_type(fcx, &**count_expr, tcx.types.usize);
let count = ty::eval_repeat_count(fcx.tcx(), &**count_expr);
let count = fcx.tcx().eval_repeat_count(&**count_expr);
let uty = match expected {
ExpectHasType(uty) => {
@ -3558,7 +3546,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
},
def => {
// Verify that this was actually a struct.
let typ = ty::lookup_item_type(fcx.ccx.tcx, def.def_id());
let typ = fcx.ccx.tcx.lookup_item_type(def.def_id());
match typ.ty.sty {
ty::TyStruct(struct_did, _) => {
check_struct_constructor(fcx,
@ -3605,7 +3593,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
.ty_to_string(
actual_structure_type),
type_error);
ty::note_and_explain_type_err(tcx, &type_error, path.span);
tcx.note_and_explain_type_err(&type_error, path.span);
}
}
}
@ -3700,7 +3688,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
};
if let Some(did) = did {
let predicates = ty::lookup_predicates(tcx, did);
let predicates = tcx.lookup_predicates(did);
let substs = Substs::new_type(vec![idx_type], vec![]);
let bounds = fcx.instantiate_bounds(expr.span, &substs, &predicates);
fcx.add_obligations_for_parameters(
@ -4096,7 +4084,7 @@ fn check_const<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
e: &'tcx ast::Expr,
id: ast::NodeId) {
let inh = static_inherited_fields(ccx);
let rty = ty::node_id_to_type(ccx.tcx, id);
let rty = ccx.tcx.node_id_to_type(id);
let fcx = blank_fn_ctxt(ccx, &inh, ty::FnConverging(rty), e.id);
let declty = fcx.ccx.tcx.tcache.borrow().get(&local_def(id)).unwrap().ty;
check_const_with_ty(&fcx, sp, e, declty);
@ -4129,14 +4117,14 @@ pub fn check_representable(tcx: &ty::ctxt,
sp: Span,
item_id: ast::NodeId,
designation: &str) -> bool {
let rty = ty::node_id_to_type(tcx, item_id);
let rty = tcx.node_id_to_type(item_id);
// Check that it is possible to represent this type. This call identifies
// (1) types that contain themselves and (2) types that contain a different
// recursive type. It is only necessary to throw an error on those that
// contain themselves. For case 2, there must be an inner type that will be
// caught by case 1.
match ty::is_type_representable(tcx, sp, rty) {
match rty.is_representable(tcx, sp) {
ty::SelfRecursive => {
span_err!(tcx.sess, sp, E0072,
"illegal recursive {} type; \
@ -4164,8 +4152,8 @@ pub fn check_instantiable(tcx: &ty::ctxt,
sp: Span,
item_id: ast::NodeId)
-> bool {
let item_ty = ty::node_id_to_type(tcx, item_id);
if !ty::is_instantiable(tcx, item_ty) {
let item_ty = tcx.node_id_to_type(item_id);
if !item_ty.is_instantiable(tcx) {
span_err!(tcx.sess, sp, E0073,
"this type cannot be instantiated without an \
instance of itself");
@ -4178,21 +4166,21 @@ pub fn check_instantiable(tcx: &ty::ctxt,
}
pub fn check_simd(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) {
let t = ty::node_id_to_type(tcx, id);
let t = tcx.node_id_to_type(id);
if t.needs_subst() {
span_err!(tcx.sess, sp, E0074, "SIMD vector cannot be generic");
return;
}
match t.sty {
ty::TyStruct(did, substs) => {
let fields = ty::lookup_struct_fields(tcx, did);
let fields = tcx.lookup_struct_fields(did);
if fields.is_empty() {
span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty");
return;
}
let e = ty::lookup_field_type(tcx, did, fields[0].id, substs);
let e = tcx.lookup_field_type(did, fields[0].id, substs);
if !fields.iter().all(
|f| ty::lookup_field_type(tcx, did, f.id, substs) == e) {
|f| tcx.lookup_field_type(did, f.id, substs) == e) {
span_err!(tcx.sess, sp, E0076, "SIMD vector should be homogeneous");
return;
}
@ -4244,13 +4232,13 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
hint: attr::ReprAttr) {
#![allow(trivial_numeric_casts)]
let rty = ty::node_id_to_type(ccx.tcx, id);
let rty = ccx.tcx.node_id_to_type(id);
let mut disr_vals: Vec<ty::Disr> = Vec::new();
let inh = static_inherited_fields(ccx);
let fcx = blank_fn_ctxt(ccx, &inh, ty::FnConverging(rty), id);
let (_, repr_type_ty) = ty::enum_repr_type(ccx.tcx, Some(&hint));
let (_, repr_type_ty) = ccx.tcx.enum_repr_type(Some(&hint));
for v in vs {
if let Some(ref e) = v.node.disr_expr {
check_const_with_ty(&fcx, e.span, e, repr_type_ty);
@ -4261,7 +4249,7 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
// ty::enum_variants guards against discriminant overflows, so
// we need not check for that.
let variants = ty::enum_variants(ccx.tcx, def_id);
let variants = ccx.tcx.enum_variants(def_id);
for (v, variant) in vs.iter().zip(variants.iter()) {
let current_disr_val = variant.disr_val;
@ -4295,7 +4283,7 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
}
}
let hint = *ty::lookup_repr_hints(ccx.tcx, ast::DefId { krate: ast::LOCAL_CRATE, node: id })
let hint = *ccx.tcx.lookup_repr_hints(ast::DefId { krate: ast::LOCAL_CRATE, node: id })
.get(0).unwrap_or(&attr::ReprAny);
if hint != attr::ReprAny && vs.len() <= 1 {
@ -4333,7 +4321,7 @@ fn type_scheme_and_predicates_for_def<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
def::DefFn(id, _) | def::DefMethod(id, _) |
def::DefStatic(id, _) | def::DefVariant(_, id, _) |
def::DefStruct(id) | def::DefConst(id) | def::DefAssociatedConst(id, _) => {
(ty::lookup_item_type(fcx.tcx(), id), ty::lookup_predicates(fcx.tcx(), id))
(fcx.tcx().lookup_item_type(id), fcx.tcx().lookup_predicates(id))
}
def::DefTrait(_) |
def::DefTy(..) |
@ -4595,7 +4583,7 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// is inherent, there is no `Self` parameter, instead, the impl needs
// type parameters, which we can infer by unifying the provided `Self`
// with the substituted impl type.
let impl_scheme = ty::lookup_item_type(fcx.tcx(), impl_def_id);
let impl_scheme = fcx.tcx().lookup_item_type(impl_def_id);
assert_eq!(substs.types.len(subst::TypeSpace),
impl_scheme.generics.types.len(subst::TypeSpace));
assert_eq!(substs.regions().len(subst::TypeSpace),
@ -5221,7 +5209,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
variadic: false,
}),
}));
let i_ty = ty::lookup_item_type(ccx.tcx, local_def(it.id));
let i_ty = ccx.tcx.lookup_item_type(local_def(it.id));
let i_n_tps = i_ty.generics.types.len(subst::FnSpace);
if i_n_tps != n_tps {
span_err!(tcx.sess, it.span, E0094,

View file

@ -56,7 +56,7 @@ pub fn check_binop_assign<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
}
let tcx = fcx.tcx();
if !ty::expr_is_lval(tcx, lhs_expr) {
if !tcx.expr_is_lval(lhs_expr) {
span_err!(tcx.sess, lhs_expr.span, E0067, "illegal left-hand side expression");
}
@ -335,7 +335,7 @@ fn lookup_op_method<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
// extract return type for method; all late bound regions
// should have been instantiated by now
let ret_ty = method_ty.fn_ret();
Ok(ty::no_late_bound_regions(fcx.tcx(), &ret_ty).unwrap().unwrap())
Ok(fcx.tcx().no_late_bound_regions(&ret_ty).unwrap().unwrap())
}
None => {
Err(())

View file

@ -265,10 +265,10 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> {
if ty_unadjusted.references_error() {
ty_unadjusted
} else {
let tcx = self.fcx.tcx();
ty::adjust_ty(tcx, expr.span, expr.id, ty_unadjusted,
self.fcx.inh.adjustments.borrow().get(&expr.id),
|method_call| self.resolve_method_type(method_call))
ty_unadjusted.adjust(
self.fcx.tcx(), expr.span, expr.id,
self.fcx.inh.adjustments.borrow().get(&expr.id),
|method_call| self.resolve_method_type(method_call))
}
}
@ -662,7 +662,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
constrain_call(rcx, expr, Some(&**base),
None::<ast::Expr>.iter(), true);
let fn_ret = // late-bound regions in overloaded method calls are instantiated
ty::no_late_bound_regions(rcx.tcx(), &method.ty.fn_ret()).unwrap();
rcx.tcx().no_late_bound_regions(&method.ty.fn_ret()).unwrap();
fn_ret.unwrap()
}
None => rcx.resolve_node_type(base.id)
@ -893,7 +893,7 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
// was applied on the base type, as that is always the case.
let fn_sig = method.ty.fn_sig();
let fn_sig = // late-bound regions should have been instantiated
ty::no_late_bound_regions(rcx.tcx(), fn_sig).unwrap();
rcx.tcx().no_late_bound_regions(fn_sig).unwrap();
let self_ty = fn_sig.inputs[0];
let (m, r) = match self_ty.sty {
ty::TyRef(r, ref m) => (m.mutbl, r),
@ -1017,9 +1017,9 @@ fn type_of_node_must_outlive<'a, 'tcx>(
// is going to fail anyway, so just stop here and let typeck
// report errors later on in the writeback phase.
let ty0 = rcx.resolve_node_type(id);
let ty = ty::adjust_ty(tcx, origin.span(), id, ty0,
rcx.fcx.inh.adjustments.borrow().get(&id),
|method_call| rcx.resolve_method_type(method_call));
let ty = ty0.adjust(tcx, origin.span(), id,
rcx.fcx.inh.adjustments.borrow().get(&id),
|method_call| rcx.resolve_method_type(method_call));
debug!("constrain_regions_in_type_of_node(\
ty={}, ty0={}, id={}, minimum_lifetime={:?})",
ty, ty0,
@ -1172,10 +1172,8 @@ fn link_region_from_node_type<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
id, mutbl, cmt_borrowed);
let rptr_ty = rcx.resolve_node_type(id);
if !rptr_ty.references_error() {
let tcx = rcx.fcx.ccx.tcx;
if let ty::TyRef(&r, _) = rptr_ty.sty {
debug!("rptr_ty={}", rptr_ty);
let r = ty::ty_region(tcx, span, rptr_ty);
link_region(rcx, span, &r, ty::BorrowKind::from_mutbl(mutbl),
cmt_borrowed);
}
@ -1462,10 +1460,8 @@ fn generic_must_outlive<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
generic);
// To start, collect bounds from user:
let mut param_bounds =
ty::required_region_bounds(rcx.tcx(),
generic.to_ty(rcx.tcx()),
param_env.caller_bounds.clone());
let mut param_bounds = rcx.tcx().required_region_bounds(generic.to_ty(rcx.tcx()),
param_env.caller_bounds.clone());
// In the case of a projection T::Foo, we may be able to extract bounds from the trait def:
match *generic {
@ -1532,7 +1528,7 @@ fn projection_bounds<'a,'tcx>(rcx: &Rcx<'a, 'tcx>,
// ```
//
// we can thus deduce that `<T as SomeTrait<'a>>::SomeType : 'a`.
let trait_predicates = ty::lookup_predicates(tcx, projection_ty.trait_ref.def_id);
let trait_predicates = tcx.lookup_predicates(projection_ty.trait_ref.def_id);
let predicates = trait_predicates.predicates.as_slice().to_vec();
traits::elaborate_predicates(tcx, predicates)
.filter_map(|predicate| {

View file

@ -136,7 +136,7 @@ impl<'a,'tcx> SeedBorrowKind<'a,'tcx> {
closure_def_id);
}
ty::with_freevars(self.tcx(), expr.id, |freevars| {
self.tcx().with_freevars(expr.id, |freevars| {
for freevar in freevars {
let var_node_id = freevar.def.local_node_id();
let upvar_id = ty::UpvarId { var_id: var_node_id,

View file

@ -16,7 +16,6 @@ use middle::region;
use middle::subst::{self, TypeSpace, FnSpace, ParamSpace, SelfSpace};
use middle::traits;
use middle::ty::{self, Ty};
use middle::ty::liberate_late_bound_regions;
use middle::ty_fold::{TypeFolder, TypeFoldable, super_fold_ty};
use std::collections::HashSet;
@ -56,7 +55,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
let ccx = self.ccx;
debug!("check_item_well_formed(it.id={}, it.ident={})",
item.id,
ty::item_path_str(ccx.tcx, local_def(item.id)));
ccx.tcx.item_path_str(local_def(item.id)));
match item.node {
/// Right now we check that every default trait implementation
@ -80,13 +79,12 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
self.check_impl(item);
}
ast::ItemImpl(_, ast::ImplPolarity::Negative, _, Some(_), _, _) => {
let trait_ref = ty::impl_trait_ref(ccx.tcx,
local_def(item.id)).unwrap();
ty::populate_implementations_for_trait_if_necessary(ccx.tcx, trait_ref.def_id);
let trait_ref = ccx.tcx.impl_trait_ref(local_def(item.id)).unwrap();
ccx.tcx.populate_implementations_for_trait_if_necessary(trait_ref.def_id);
match ccx.tcx.lang_items.to_builtin_kind(trait_ref.def_id) {
Some(ty::BoundSend) | Some(ty::BoundSync) => {}
Some(_) | None => {
if !ty::trait_has_default_impl(ccx.tcx, trait_ref.def_id) {
if !ccx.tcx.trait_has_default_impl(trait_ref.def_id) {
span_err!(ccx.tcx.sess, item.span, E0192,
"negative impls are only allowed for traits with \
default impls (e.g., `Send` and `Sync`)")
@ -119,9 +117,9 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
}
ast::ItemTrait(_, _, _, ref items) => {
let trait_predicates =
ty::lookup_predicates(ccx.tcx, local_def(item.id));
ccx.tcx.lookup_predicates(local_def(item.id));
reject_non_type_param_bounds(ccx.tcx, item.span, &trait_predicates);
if ty::trait_has_default_impl(ccx.tcx, local_def(item.id)) {
if ccx.tcx.trait_has_default_impl(local_def(item.id)) {
if !items.is_empty() {
span_err!(ccx.tcx.sess, item.span, E0380,
"traits with default impls (`e.g. unsafe impl \
@ -138,15 +136,13 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
{
let ccx = self.ccx;
let item_def_id = local_def(item.id);
let type_scheme = ty::lookup_item_type(ccx.tcx, item_def_id);
let type_predicates = ty::lookup_predicates(ccx.tcx, item_def_id);
let type_scheme = ccx.tcx.lookup_item_type(item_def_id);
let type_predicates = ccx.tcx.lookup_predicates(item_def_id);
reject_non_type_param_bounds(ccx.tcx, item.span, &type_predicates);
let param_env =
ty::construct_parameter_environment(ccx.tcx,
item.span,
&type_scheme.generics,
&type_predicates,
item.id);
let param_env = ccx.tcx.construct_parameter_environment(item.span,
&type_scheme.generics,
&type_predicates,
item.id);
let inh = Inherited::new(ccx.tcx, param_env);
let fcx = blank_fn_ctxt(ccx, &inh, ty::FnConverging(type_scheme.ty), item.id);
f(self, &fcx);
@ -201,7 +197,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
Some(&mut this.cache));
debug!("check_item_type at bounds_checker.scope: {:?}", bounds_checker.scope);
let type_scheme = ty::lookup_item_type(fcx.tcx(), local_def(item.id));
let type_scheme = fcx.tcx().lookup_item_type(local_def(item.id));
let item_ty = fcx.instantiate_type_scheme(item.span,
&fcx.inh.param_env.free_substs,
&type_scheme.ty);
@ -222,7 +218,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
// Find the impl self type as seen from the "inside" --
// that is, with all type parameters converted from bound
// to free.
let self_ty = ty::node_id_to_type(fcx.tcx(), item.id);
let self_ty = fcx.tcx().node_id_to_type(item.id);
let self_ty = fcx.instantiate_type_scheme(item.span,
&fcx.inh.param_env.free_substs,
&self_ty);
@ -231,7 +227,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
// Similarly, obtain an "inside" reference to the trait
// that the impl implements.
let trait_ref = match ty::impl_trait_ref(fcx.tcx(), local_def(item.id)) {
let trait_ref = match fcx.tcx().impl_trait_ref(local_def(item.id)) {
None => { return; }
Some(t) => { t }
};
@ -258,7 +254,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
// Find the supertrait bounds. This will add `int:Bar`.
let poly_trait_ref = ty::Binder(trait_ref);
let predicates = ty::lookup_super_predicates(fcx.tcx(), poly_trait_ref.def_id());
let predicates = fcx.tcx().lookup_super_predicates(poly_trait_ref.def_id());
let predicates = predicates.instantiate_supertrait(fcx.tcx(), &poly_trait_ref);
let predicates = {
let selcx = &mut traits::SelectionContext::new(fcx.infcx(), fcx);
@ -278,8 +274,8 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
ast_generics: &ast::Generics)
{
let item_def_id = local_def(item.id);
let ty_predicates = ty::lookup_predicates(self.tcx(), item_def_id);
let variances = ty::item_variances(self.tcx(), item_def_id);
let ty_predicates = self.tcx().lookup_predicates(item_def_id);
let variances = self.tcx().item_variances(item_def_id);
let mut constrained_parameters: HashSet<_> =
variances.types
@ -358,7 +354,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
span,
&format!("consider removing `{}` or using a marker such as `{}`",
param_name,
ty::item_path_str(self.tcx(), def_id)));
self.tcx().item_path_str(def_id)));
}
None => {
// no lang items, no help!
@ -432,7 +428,7 @@ impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> {
match fk {
visit::FkFnBlock | visit::FkItemFn(..) => {}
visit::FkMethod(..) => {
match ty::impl_or_trait_item(self.tcx(), local_def(id)) {
match self.tcx().impl_or_trait_item(local_def(id)) {
ty::ImplOrTraitItem::MethodTraitItem(ty_method) => {
reject_shadowing_type_parameters(self.tcx(), span, &ty_method.generics)
}
@ -445,7 +441,7 @@ impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> {
fn visit_trait_item(&mut self, trait_item: &'v ast::TraitItem) {
if let ast::MethodTraitItem(_, None) = trait_item.node {
match ty::impl_or_trait_item(self.tcx(), local_def(trait_item.id)) {
match self.tcx().impl_or_trait_item(local_def(trait_item.id)) {
ty::ImplOrTraitItem::MethodTraitItem(ty_method) => {
reject_non_type_param_bounds(
self.tcx(),
@ -496,7 +492,7 @@ impl<'cx,'tcx> BoundsChecker<'cx,'tcx> {
/// Note that it does not (currently, at least) check that `A : Copy` (that check is delegated
/// to the point where impl `A : Trait<B>` is implemented).
pub fn check_trait_ref(&mut self, trait_ref: &ty::TraitRef<'tcx>, span: Span) {
let trait_predicates = ty::lookup_predicates(self.fcx.tcx(), trait_ref.def_id);
let trait_predicates = self.fcx.tcx().lookup_predicates(trait_ref.def_id);
let bounds = self.fcx.instantiate_bounds(span,
trait_ref.substs,
@ -538,8 +534,7 @@ impl<'cx,'tcx> TypeFolder<'tcx> for BoundsChecker<'cx,'tcx> {
where T : TypeFoldable<'tcx>
{
self.binding_count += 1;
let value = liberate_late_bound_regions(
self.fcx.tcx(),
let value = self.fcx.tcx().liberate_late_bound_regions(
region::DestructionScopeData::new(self.scope),
binder);
debug!("BoundsChecker::fold_binder: late-bound regions replaced: {:?} at scope: {:?}",
@ -567,7 +562,7 @@ impl<'cx,'tcx> TypeFolder<'tcx> for BoundsChecker<'cx,'tcx> {
match t.sty{
ty::TyStruct(type_id, substs) |
ty::TyEnum(type_id, substs) => {
let type_predicates = ty::lookup_predicates(self.fcx.tcx(), type_id);
let type_predicates = self.fcx.tcx().lookup_predicates(type_id);
let bounds = self.fcx.instantiate_bounds(self.span, substs,
&type_predicates);
@ -638,7 +633,7 @@ fn struct_variant<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
struct_def.fields
.iter()
.map(|field| {
let field_ty = ty::node_id_to_type(fcx.tcx(), field.node.id);
let field_ty = fcx.tcx().node_id_to_type(field.node.id);
let field_ty = fcx.instantiate_type_scheme(field.span,
&fcx.inh.param_env.free_substs,
&field_ty);
@ -655,13 +650,11 @@ fn enum_variants<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
.map(|variant| {
match variant.node.kind {
ast::TupleVariantKind(ref args) if !args.is_empty() => {
let ctor_ty = ty::node_id_to_type(fcx.tcx(), variant.node.id);
let ctor_ty = fcx.tcx().node_id_to_type(variant.node.id);
// the regions in the argument types come from the
// enum def'n, and hence will all be early bound
let arg_tys =
ty::no_late_bound_regions(
fcx.tcx(), &ctor_ty.fn_args()).unwrap();
let arg_tys = fcx.tcx().no_late_bound_regions(&ctor_ty.fn_args()).unwrap();
AdtVariant {
fields: args.iter().enumerate().map(|(index, arg)| {
let arg_ty = arg_tys[index];

View file

@ -171,7 +171,7 @@ impl<'cx, 'tcx, 'v> Visitor<'v> for WritebackCx<'cx, 'tcx> {
debug!("Type for pattern binding {} (id {}) resolved to {:?}",
pat_to_string(p),
p.id,
ty::node_id_to_type(self.tcx(), p.id));
self.tcx().node_id_to_type(p.id));
visit::walk_pat(self, p);
}
@ -334,11 +334,11 @@ impl ResolveReason {
ResolvingLocal(s) => s,
ResolvingPattern(s) => s,
ResolvingUpvar(upvar_id) => {
ty::expr_span(tcx, upvar_id.closure_expr_id)
tcx.expr_span(upvar_id.closure_expr_id)
}
ResolvingClosure(did) => {
if did.krate == ast::LOCAL_CRATE {
ty::expr_span(tcx, did.node)
tcx.expr_span(did.node)
} else {
DUMMY_SP
}
@ -403,7 +403,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
let span = self.reason.span(self.tcx);
span_err!(self.tcx.sess, span, E0104,
"cannot resolve lifetime for captured variable `{}`: {}",
ty::local_var_name_str(self.tcx, upvar_id.var_id).to_string(),
self.tcx.local_var_name_str(upvar_id.var_id).to_string(),
infer::fixup_err_to_string(e));
}

View file

@ -139,15 +139,14 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
fn check_implementation(&self, item: &Item) {
let tcx = self.crate_context.tcx;
let impl_did = local_def(item.id);
let self_type = ty::lookup_item_type(tcx, impl_did);
let self_type = tcx.lookup_item_type(impl_did);
// If there are no traits, then this implementation must have a
// base type.
let impl_items = self.create_impl_from_item(item);
if let Some(trait_ref) = ty::impl_trait_ref(self.crate_context.tcx,
impl_did) {
if let Some(trait_ref) = self.crate_context.tcx.impl_trait_ref(impl_did) {
debug!("(checking implementation) adding impl for trait '{:?}', item '{}'",
trait_ref,
item.ident);
@ -181,9 +180,9 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
debug!("instantiate_default_methods(impl_id={:?}, trait_ref={:?})",
impl_id, trait_ref);
let impl_type_scheme = ty::lookup_item_type(tcx, impl_id);
let impl_type_scheme = tcx.lookup_item_type(impl_id);
let prov = ty::provided_trait_methods(tcx, trait_ref.def_id);
let prov = tcx.provided_trait_methods(trait_ref.def_id);
for trait_method in &prov {
// Synthesize an ID.
let new_id = tcx.sess.next_node_id();
@ -245,8 +244,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
fn add_trait_impl(&self, impl_trait_ref: ty::TraitRef<'tcx>, impl_def_id: DefId) {
debug!("add_trait_impl: impl_trait_ref={:?} impl_def_id={:?}",
impl_trait_ref, impl_def_id);
let trait_def = ty::lookup_trait_def(self.crate_context.tcx,
impl_trait_ref.def_id);
let trait_def = self.crate_context.tcx.lookup_trait_def(impl_trait_ref.def_id);
trait_def.record_impl(self.crate_context.tcx, impl_def_id, impl_trait_ref);
}
@ -273,11 +271,9 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
}
}).collect();
if let Some(trait_ref) = ty::impl_trait_ref(self.crate_context.tcx,
local_def(item.id)) {
self.instantiate_default_methods(local_def(item.id),
&trait_ref,
&mut items);
let def_id = local_def(item.id);
if let Some(trait_ref) = self.crate_context.tcx.impl_trait_ref(def_id) {
self.instantiate_default_methods(def_id, &trait_ref, &mut items);
}
items
@ -299,8 +295,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
let drop_trait = match tcx.lang_items.drop_trait() {
Some(id) => id, None => { return }
};
ty::populate_implementations_for_trait_if_necessary(tcx, drop_trait);
let drop_trait = ty::lookup_trait_def(tcx, drop_trait);
tcx.populate_implementations_for_trait_if_necessary(drop_trait);
let drop_trait = tcx.lookup_trait_def(drop_trait);
let impl_items = tcx.impl_items.borrow();
@ -312,7 +308,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
}
let method_def_id = items[0];
let self_type = ty::lookup_item_type(tcx, impl_did);
let self_type = tcx.lookup_item_type(impl_did);
match self_type.ty.sty {
ty::TyEnum(type_def_id, _) |
ty::TyStruct(type_def_id, _) |
@ -355,8 +351,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
Some(id) => id,
None => return,
};
ty::populate_implementations_for_trait_if_necessary(tcx, copy_trait);
let copy_trait = ty::lookup_trait_def(tcx, copy_trait);
tcx.populate_implementations_for_trait_if_necessary(copy_trait);
let copy_trait = tcx.lookup_trait_def(copy_trait);
copy_trait.for_each_impl(tcx, |impl_did| {
debug!("check_implementations_of_copy: impl_did={:?}",
@ -368,7 +364,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
return
}
let self_type = ty::lookup_item_type(tcx, impl_did);
let self_type = tcx.lookup_item_type(impl_did);
debug!("check_implementations_of_copy: self_type={:?} (bound)",
self_type);
@ -380,7 +376,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
debug!("check_implementations_of_copy: self_type={:?} (free)",
self_type);
match ty::can_type_implement_copy(&param_env, span, self_type) {
match param_env.can_type_implement_copy(self_type, span) {
Ok(()) => {}
Err(ty::FieldDoesNotImplementCopy(name)) => {
span_err!(tcx.sess, span, E0204,
@ -425,7 +421,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
}
};
let trait_def = ty::lookup_trait_def(tcx, coerce_unsized_trait);
let trait_def = tcx.lookup_trait_def(coerce_unsized_trait);
trait_def.for_each_impl(tcx, |impl_did| {
debug!("check_implementations_of_coerce_unsized: impl_did={:?}",
@ -437,9 +433,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
return;
}
let source = ty::lookup_item_type(tcx, impl_did).ty;
let trait_ref = ty::impl_trait_ref(self.crate_context.tcx,
impl_did).unwrap();
let source = tcx.lookup_item_type(impl_did).ty;
let trait_ref = self.crate_context.tcx.impl_trait_ref(impl_did).unwrap();
let target = *trait_ref.substs.types.get(subst::TypeSpace, 0);
debug!("check_implementations_of_coerce_unsized: {:?} -> {:?} (bound)",
source, target);
@ -478,8 +473,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
(&ty::TyStruct(def_id_a, substs_a), &ty::TyStruct(def_id_b, substs_b)) => {
if def_id_a != def_id_b {
let source_path = ty::item_path_str(tcx, def_id_a);
let target_path = ty::item_path_str(tcx, def_id_b);
let source_path = tcx.item_path_str(def_id_a);
let target_path = tcx.item_path_str(def_id_b);
span_err!(tcx.sess, span, E0377,
"the trait `CoerceUnsized` may only be implemented \
for a coercion between structures with the same \
@ -489,9 +484,9 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
}
let origin = infer::Misc(span);
let fields = ty::lookup_struct_fields(tcx, def_id_a);
let fields = tcx.lookup_struct_fields(def_id_a);
let diff_fields = fields.iter().enumerate().filter_map(|(i, f)| {
let ty = ty::lookup_field_type_unsubstituted(tcx, def_id_a, f.id);
let ty = tcx.lookup_field_type_unsubstituted(def_id_a, f.id);
let (a, b) = (ty.subst(tcx, substs_a), ty.subst(tcx, substs_b));
if infcx.sub_types(false, origin, b, a).is_ok() {
None
@ -592,7 +587,7 @@ fn subst_receiver_types_in_method_ty<'tcx>(tcx: &ty::ctxt<'tcx>,
provided_source: Option<ast::DefId>)
-> ty::Method<'tcx>
{
let combined_substs = ty::make_substs_for_receiver_types(tcx, trait_ref, method);
let combined_substs = tcx.make_substs_for_receiver_types(trait_ref, method);
debug!("subst_receiver_types_in_method_ty: combined_substs={:?}",
combined_substs);

View file

@ -67,7 +67,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
// defined in this crate.
debug!("coherence2::orphan check: inherent impl {}",
self.tcx.map.node_to_string(item.id));
let self_ty = ty::lookup_item_type(self.tcx, def_id).ty;
let self_ty = self.tcx.lookup_item_type(def_id).ty;
match self_ty.sty {
ty::TyEnum(def_id, _) |
ty::TyStruct(def_id, _) => {
@ -210,7 +210,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
// "Trait" impl
debug!("coherence2::orphan check: trait impl {}",
self.tcx.map.node_to_string(item.id));
let trait_ref = ty::impl_trait_ref(self.tcx, def_id).unwrap();
let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap();
let trait_def_id = trait_ref.def_id;
match traits::orphan_check(self.tcx, def_id) {
Ok(()) => { }
@ -269,9 +269,9 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
debug!("trait_ref={:?} trait_def_id={:?} trait_has_default_impl={}",
trait_ref,
trait_def_id,
ty::trait_has_default_impl(self.tcx, trait_def_id));
self.tcx.trait_has_default_impl(trait_def_id));
if
ty::trait_has_default_impl(self.tcx, trait_def_id) &&
self.tcx.trait_has_default_impl(trait_def_id) &&
trait_def_id.krate != ast::LOCAL_CRATE
{
let self_ty = trait_ref.self_ty();
@ -297,7 +297,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
"cross-crate traits with a default impl, like `{}`, \
can only be implemented for a struct/enum type \
defined in the current crate",
ty::item_path_str(self.tcx, trait_def_id)))
self.tcx.item_path_str(trait_def_id)))
}
}
_ => {
@ -305,7 +305,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
"cross-crate traits with a default impl, like `{}`, \
can only be implemented for a struct/enum type, \
not `{}`",
ty::item_path_str(self.tcx, trait_def_id),
self.tcx.item_path_str(trait_def_id),
self_ty))
}
};
@ -332,7 +332,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
// "Trait" impl
debug!("coherence2::orphan check: default trait impl {}",
self.tcx.map.node_to_string(item.id));
let trait_ref = ty::impl_trait_ref(self.tcx, def_id).unwrap();
let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap();
if trait_ref.def_id.krate != ast::LOCAL_CRATE {
span_err!(self.tcx.sess, item.span, E0318,
"cannot create default implementations for traits outside the \

View file

@ -50,9 +50,7 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
let trait_defs: Vec<_> = self.tcx.trait_defs.borrow().values().cloned().collect();
for trait_def in trait_defs {
ty::populate_implementations_for_trait_if_necessary(
self.tcx,
trait_def.trait_ref.def_id);
self.tcx.populate_implementations_for_trait_if_necessary(trait_def.trait_ref.def_id);
self.check_for_overlapping_impls_of_trait(trait_def);
}
}
@ -147,7 +145,7 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
span_err!(self.tcx.sess, self.span_of_impl(impl1), E0119,
"conflicting implementations for trait `{}`",
ty::item_path_str(self.tcx, trait_def_id));
self.tcx.item_path_str(trait_def_id));
self.report_overlap_note(impl1, impl2);
}
@ -181,7 +179,7 @@ impl<'cx, 'tcx,'v> visit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
// general orphan/coherence rules, it must always be
// in this crate.
let impl_def_id = ast_util::local_def(item.id);
let trait_ref = ty::impl_trait_ref(self.tcx, impl_def_id).unwrap();
let trait_ref = self.tcx.impl_trait_ref(impl_def_id).unwrap();
let prev_default_impl = self.default_impls.insert(trait_ref.def_id, item.id);
match prev_default_impl {
Some(prev_id) => {
@ -194,7 +192,7 @@ impl<'cx, 'tcx,'v> visit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
}
ast::ItemImpl(_, _, _, Some(_), ref self_ty, _) => {
let impl_def_id = ast_util::local_def(item.id);
let trait_ref = ty::impl_trait_ref(self.tcx, impl_def_id).unwrap();
let trait_ref = self.tcx.impl_trait_ref(impl_def_id).unwrap();
let trait_def_id = trait_ref.def_id;
match trait_ref.self_ty().sty {
ty::TyTrait(ref data) => {
@ -208,7 +206,7 @@ impl<'cx, 'tcx,'v> visit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
// giving a misleading message below.
span_err!(self.tcx.sess, self_ty.span, E0372,
"the trait `{}` cannot be made into an object",
ty::item_path_str(self.tcx, data.principal_def_id()));
self.tcx.item_path_str(data.principal_def_id()));
} else {
let mut supertrait_def_ids =
traits::supertrait_def_ids(self.tcx, data.principal_def_id());
@ -217,7 +215,7 @@ impl<'cx, 'tcx,'v> visit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
"the object type `{}` automatically \
implements the trait `{}`",
trait_ref.self_ty(),
ty::item_path_str(self.tcx, trait_def_id));
self.tcx.item_path_str(trait_def_id));
}
}
}

View file

@ -30,7 +30,7 @@ impl<'cx, 'tcx, 'v> UnsafetyChecker<'cx, 'tcx> {
fn check_unsafety_coherence(&mut self, item: &'v ast::Item,
unsafety: ast::Unsafety,
polarity: ast::ImplPolarity) {
match ty::impl_trait_ref(self.tcx, ast_util::local_def(item.id)) {
match self.tcx.impl_trait_ref(ast_util::local_def(item.id)) {
None => {
// Inherent impl.
match unsafety {
@ -43,7 +43,7 @@ impl<'cx, 'tcx, 'v> UnsafetyChecker<'cx, 'tcx> {
}
Some(trait_ref) => {
let trait_def = ty::lookup_trait_def(self.tcx, trait_ref.def_id);
let trait_def = self.tcx.lookup_trait_def(trait_ref.def_id);
match (trait_def.unsafety, unsafety, polarity) {
(ast::Unsafety::Unsafe,
ast::Unsafety::Unsafe, ast::ImplPolarity::Negative) => {

View file

@ -242,12 +242,12 @@ impl<'a,'tcx> CrateCtxt<'a,'tcx> {
AstConvRequest::GetTraitDef(def_id) => {
tcx.sess.note(
&format!("the cycle begins when processing `{}`...",
ty::item_path_str(tcx, def_id)));
tcx.item_path_str(def_id)));
}
AstConvRequest::EnsureSuperPredicates(def_id) => {
tcx.sess.note(
&format!("the cycle begins when computing the supertraits of `{}`...",
ty::item_path_str(tcx, def_id)));
tcx.item_path_str(def_id)));
}
AstConvRequest::GetTypeParameterBounds(id) => {
let def = tcx.type_parameter_def(id);
@ -264,12 +264,12 @@ impl<'a,'tcx> CrateCtxt<'a,'tcx> {
AstConvRequest::GetTraitDef(def_id) => {
tcx.sess.note(
&format!("...which then requires processing `{}`...",
ty::item_path_str(tcx, def_id)));
tcx.item_path_str(def_id)));
}
AstConvRequest::EnsureSuperPredicates(def_id) => {
tcx.sess.note(
&format!("...which then requires computing the supertraits of `{}`...",
ty::item_path_str(tcx, def_id)));
tcx.item_path_str(def_id)));
}
AstConvRequest::GetTypeParameterBounds(id) => {
let def = tcx.type_parameter_def(id);
@ -286,13 +286,13 @@ impl<'a,'tcx> CrateCtxt<'a,'tcx> {
AstConvRequest::GetTraitDef(def_id) => {
tcx.sess.note(
&format!("...which then again requires processing `{}`, completing the cycle.",
ty::item_path_str(tcx, def_id)));
tcx.item_path_str(def_id)));
}
AstConvRequest::EnsureSuperPredicates(def_id) => {
tcx.sess.note(
&format!("...which then again requires computing the supertraits of `{}`, \
completing the cycle.",
ty::item_path_str(tcx, def_id)));
tcx.item_path_str(def_id)));
}
AstConvRequest::GetTypeParameterBounds(id) => {
let def = tcx.type_parameter_def(id);
@ -311,7 +311,7 @@ impl<'a,'tcx> CrateCtxt<'a,'tcx> {
let tcx = self.tcx;
if trait_id.krate != ast::LOCAL_CRATE {
return ty::lookup_trait_def(tcx, trait_id)
return tcx.lookup_trait_def(trait_id)
}
let item = match tcx.map.get(trait_id.node) {
@ -399,7 +399,7 @@ impl<'a, 'tcx> AstConv<'tcx> for ItemCtxt<'a, 'tcx> {
if trait_def_id.krate == ast::LOCAL_CRATE {
trait_defines_associated_type_named(self.ccx, trait_def_id.node, assoc_name)
} else {
let trait_def = ty::lookup_trait_def(self.tcx(), trait_def_id);
let trait_def = self.tcx().lookup_trait_def(trait_def_id);
trait_def.associated_type_names.contains(&assoc_name)
}
}
@ -822,7 +822,7 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
ast_trait_ref,
None);
ty::record_trait_has_default_impl(tcx, trait_ref.def_id);
tcx.record_trait_has_default_impl(trait_ref.def_id);
tcx.impl_trait_refs.borrow_mut().insert(local_def(it.id), Some(trait_ref));
}
@ -944,7 +944,7 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
let _: Result<(), ErrorReported> = // any error is already reported, can ignore
ccx.ensure_super_predicates(it.span, local_def(it.id));
convert_trait_predicates(ccx, it);
let trait_predicates = ty::lookup_predicates(tcx, local_def(it.id));
let trait_predicates = tcx.lookup_predicates(local_def(it.id));
debug!("convert: trait_bounds={:?}", trait_predicates);
@ -1230,7 +1230,7 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
_ => tcx.sess.span_bug(it.span, "trait_def_of_item invoked on non-trait"),
};
let paren_sugar = ty::has_attr(tcx, def_id, "rustc_paren_sugar");
let paren_sugar = tcx.has_attr(def_id, "rustc_paren_sugar");
if paren_sugar && !ccx.tcx.sess.features.borrow().unboxed_closures {
ccx.tcx.sess.span_err(
it.span,
@ -1343,7 +1343,7 @@ fn convert_trait_predicates<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &ast::Item)
}
};
let super_predicates = ty::lookup_super_predicates(ccx.tcx, def_id);
let super_predicates = ccx.tcx.lookup_super_predicates(def_id);
// `ty_generic_predicates` below will consider the bounds on the type
// parameters (including `Self`) and the explicit where-clauses,
@ -1407,7 +1407,7 @@ fn type_scheme_of_def_id<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
-> ty::TypeScheme<'tcx>
{
if def_id.krate != ast::LOCAL_CRATE {
return ty::lookup_item_type(ccx.tcx, def_id);
return ccx.tcx.lookup_item_type(def_id);
}
match ccx.tcx.map.find(def_id.node) {
@ -1529,7 +1529,7 @@ fn convert_typed_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
assert!(prev_predicates.is_none());
// Debugging aid.
if ty::has_attr(tcx, local_def(it.id), "rustc_object_lifetime_default") {
if tcx.has_attr(local_def(it.id), "rustc_object_lifetime_default") {
let object_lifetime_default_reprs: String =
scheme.generics.types.iter()
.map(|t| match t.object_lifetime_default {
@ -1691,20 +1691,20 @@ fn add_unsized_bound<'tcx>(astconv: &AstConv<'tcx>,
match unbound {
Some(ref tpb) => {
// FIXME(#8559) currently requires the unbound to be built-in.
let trait_def_id = ty::trait_ref_to_def_id(tcx, tpb);
let trait_def_id = tcx.trait_ref_to_def_id(tpb);
match kind_id {
Ok(kind_id) if trait_def_id != kind_id => {
tcx.sess.span_warn(span,
"default bound relaxed for a type parameter, but \
this does nothing because the given bound is not \
a default. Only `?Sized` is supported");
ty::try_add_builtin_trait(tcx, kind_id, bounds);
tcx.try_add_builtin_trait(kind_id, bounds);
}
_ => {}
}
}
_ if kind_id.is_ok() => {
ty::try_add_builtin_trait(tcx, kind_id.unwrap(), bounds);
tcx.try_add_builtin_trait(kind_id.unwrap(), bounds);
}
// No lang item for Sized, so we can't add it as a bound.
None => {}
@ -2187,8 +2187,7 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>(
let required_type_free =
liberate_early_bound_regions(
tcx, body_scope,
&ty::liberate_late_bound_regions(
tcx, body_scope, &ty::Binder(required_type)));
&tcx.liberate_late_bound_regions(body_scope, &ty::Binder(required_type)));
// The "base type" comes from the impl. It too may have late-bound
// regions from the method.
@ -2196,8 +2195,7 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>(
let base_type_free =
liberate_early_bound_regions(
tcx, body_scope,
&ty::liberate_late_bound_regions(
tcx, body_scope, &ty::Binder(base_type)));
&tcx.liberate_late_bound_regions(body_scope, &ty::Binder(base_type)));
debug!("required_type={:?} required_type_free={:?} \
base_type={:?} base_type_free={:?}",
@ -2262,9 +2260,9 @@ fn enforce_impl_params_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>,
impl_def_id: ast::DefId,
impl_items: &[P<ast::ImplItem>])
{
let impl_scheme = ty::lookup_item_type(tcx, impl_def_id);
let impl_predicates = ty::lookup_predicates(tcx, impl_def_id);
let impl_trait_ref = ty::impl_trait_ref(tcx, impl_def_id);
let impl_scheme = tcx.lookup_item_type(impl_def_id);
let impl_predicates = tcx.lookup_predicates(impl_def_id);
let impl_trait_ref = tcx.impl_trait_ref(impl_def_id);
// The trait reference is an input, so find all type parameters
// reachable from there, to start (if this is an inherent impl,
@ -2293,7 +2291,7 @@ fn enforce_impl_params_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>,
let lifetimes_in_associated_types: HashSet<_> =
impl_items.iter()
.map(|item| ty::impl_or_trait_item(tcx, local_def(item.id)))
.map(|item| tcx.impl_or_trait_item(local_def(item.id)))
.filter_map(|item| match item {
ty::TypeTraitItem(ref assoc_ty) => assoc_ty.ty,
ty::ConstTraitItem(..) | ty::MethodTraitItem(..) => None

View file

@ -199,7 +199,7 @@ fn require_same_types<'a, 'tcx, M>(tcx: &ty::ctxt<'tcx>,
Ok(_) => true,
Err(ref terr) => {
span_err!(tcx.sess, span, E0211, "{}: {}", msg(), terr);
ty::note_and_explain_type_err(tcx, terr, span);
tcx.note_and_explain_type_err(terr, span);
false
}
}
@ -209,7 +209,7 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
main_id: ast::NodeId,
main_span: Span) {
let tcx = ccx.tcx;
let main_t = ty::node_id_to_type(tcx, main_id);
let main_t = tcx.node_id_to_type(main_id);
match main_t.sty {
ty::TyBareFn(..) => {
match tcx.map.find(main_id) {
@ -254,7 +254,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
start_id: ast::NodeId,
start_span: Span) {
let tcx = ccx.tcx;
let start_t = ty::node_id_to_type(tcx, start_id);
let start_t = tcx.node_id_to_type(start_id);
match start_t.sty {
ty::TyBareFn(..) => {
match tcx.map.find(start_id) {

View file

@ -485,7 +485,7 @@ impl<'a, 'tcx> TermsContext<'a, 'tcx> {
param_id={}, \
inf_index={:?}, \
initial_variance={:?})",
ty::item_path_str(self.tcx, ast_util::local_def(item_id)),
self.tcx.item_path_str(ast_util::local_def(item_id)),
item_id, kind, space, index, param_id, inf_index,
initial_variance);
}
@ -603,7 +603,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ConstraintContext<'a, 'tcx> {
match item.node {
ast::ItemEnum(ref enum_definition, _) => {
let scheme = ty::lookup_item_type(tcx, did);
let scheme = tcx.lookup_item_type(did);
// Not entirely obvious: constraints on structs/enums do not
// affect the variance of their type parameters. See discussion
@ -633,7 +633,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ConstraintContext<'a, 'tcx> {
}
ast::ItemStruct(..) => {
let scheme = ty::lookup_item_type(tcx, did);
let scheme = tcx.lookup_item_type(did);
// Not entirely obvious: constraints on structs/enums do not
// affect the variance of their type parameters. See discussion
@ -641,16 +641,16 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ConstraintContext<'a, 'tcx> {
//
// self.add_constraints_from_generics(&scheme.generics);
let struct_fields = ty::lookup_struct_fields(tcx, did);
let struct_fields = tcx.lookup_struct_fields(did);
for field_info in &struct_fields {
assert_eq!(field_info.id.krate, ast::LOCAL_CRATE);
let field_ty = ty::node_id_to_type(tcx, field_info.id.node);
let field_ty = tcx.node_id_to_type(field_info.id.node);
self.add_constraints_from_ty(&scheme.generics, field_ty, self.covariant);
}
}
ast::ItemTrait(..) => {
let trait_def = ty::lookup_trait_def(tcx, did);
let trait_def = tcx.lookup_trait_def(did);
self.add_constraints_from_trait_ref(&trait_def.generics,
trait_def.trait_ref,
self.invariant);
@ -781,7 +781,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
} else {
// Parameter on an item defined within another crate:
// variance already inferred, just look it up.
let variances = ty::item_variances(self.tcx(), item_def_id);
let variances = self.tcx().item_variances(item_def_id);
let variance = match kind {
TypeParam => *variances.types.get(space, index),
RegionParam => *variances.regions.get(space, index),
@ -848,7 +848,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
trait_ref,
variance);
let trait_def = ty::lookup_trait_def(self.tcx(), trait_ref.def_id);
let trait_def = self.tcx().lookup_trait_def(trait_ref.def_id);
self.add_constraints_from_substs(
generics,
@ -904,7 +904,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
ty::TyEnum(def_id, substs) |
ty::TyStruct(def_id, substs) => {
let item_type = ty::lookup_item_type(self.tcx(), def_id);
let item_type = self.tcx().lookup_item_type(def_id);
// All type parameters on enums and structs should be
// in the TypeSpace.
@ -924,7 +924,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
ty::TyProjection(ref data) => {
let trait_ref = &data.trait_ref;
let trait_def = ty::lookup_trait_def(self.tcx(), trait_ref.def_id);
let trait_def = self.tcx().lookup_trait_def(trait_ref.def_id);
self.add_constraints_from_substs(
generics,
trait_ref.def_id,
@ -1200,7 +1200,7 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> {
// For unit testing: check for a special "rustc_variance"
// attribute and report an error with various results if found.
if ty::has_attr(tcx, item_def_id, "rustc_variance") {
if tcx.has_attr(item_def_id, "rustc_variance") {
span_err!(tcx.sess, tcx.map.span(item_id), E0208, "{:?}", item_variances);
}

View file

@ -150,9 +150,9 @@ pub fn record_extern_fqn(cx: &DocContext, did: ast::DefId, kind: clean::TypeKind
pub fn build_external_trait(cx: &DocContext, tcx: &ty::ctxt,
did: ast::DefId) -> clean::Trait {
let def = ty::lookup_trait_def(tcx, did);
let trait_items = ty::trait_items(tcx, did).clean(cx);
let predicates = ty::lookup_predicates(tcx, did);
let def = tcx.lookup_trait_def(did);
let trait_items = tcx.trait_items(did).clean(cx);
let predicates = tcx.lookup_predicates(did);
let generics = (&def.generics, &predicates, subst::TypeSpace).clean(cx);
let generics = filter_non_trait_generics(did, generics);
let (generics, supertrait_bounds) = separate_supertrait_bounds(generics);
@ -165,12 +165,12 @@ pub fn build_external_trait(cx: &DocContext, tcx: &ty::ctxt,
}
fn build_external_function(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::Function {
let t = ty::lookup_item_type(tcx, did);
let t = tcx.lookup_item_type(did);
let (decl, style, abi) = match t.ty.sty {
ty::TyBareFn(_, ref f) => ((did, &f.sig).clean(cx), f.unsafety, f.abi),
_ => panic!("bad function"),
};
let predicates = ty::lookup_predicates(tcx, did);
let predicates = tcx.lookup_predicates(did);
clean::Function {
decl: decl,
generics: (&t.generics, &predicates, subst::FnSpace).clean(cx),
@ -183,9 +183,9 @@ fn build_external_function(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) ->
fn build_struct(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::Struct {
use syntax::parse::token::special_idents::unnamed_field;
let t = ty::lookup_item_type(tcx, did);
let predicates = ty::lookup_predicates(tcx, did);
let fields = ty::lookup_struct_fields(tcx, did);
let t = tcx.lookup_item_type(did);
let predicates = tcx.lookup_predicates(did);
let fields = tcx.lookup_struct_fields(did);
clean::Struct {
struct_type: match &*fields {
@ -201,14 +201,14 @@ fn build_struct(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::Stru
}
fn build_type(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::ItemEnum {
let t = ty::lookup_item_type(tcx, did);
let predicates = ty::lookup_predicates(tcx, did);
let t = tcx.lookup_item_type(did);
let predicates = tcx.lookup_predicates(did);
match t.ty.sty {
ty::TyEnum(edid, _) if !csearch::is_typedef(&tcx.sess.cstore, did) => {
return clean::EnumItem(clean::Enum {
generics: (&t.generics, &predicates, subst::TypeSpace).clean(cx),
variants_stripped: false,
variants: ty::enum_variants(tcx, edid).clean(cx),
variants: tcx.enum_variants(edid).clean(cx),
})
}
_ => {}
@ -222,7 +222,7 @@ fn build_type(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::ItemEn
pub fn build_impls(cx: &DocContext, tcx: &ty::ctxt,
did: ast::DefId) -> Vec<clean::Item> {
ty::populate_inherent_implementations_for_type_if_necessary(tcx, did);
tcx.populate_inherent_implementations_for_type_if_necessary(did);
let mut impls = Vec::new();
match tcx.inherent_impls.borrow().get(&did) {
@ -307,16 +307,16 @@ pub fn build_impl(cx: &DocContext,
});
}
let predicates = ty::lookup_predicates(tcx, did);
let predicates = tcx.lookup_predicates(did);
let trait_items = csearch::get_impl_items(&tcx.sess.cstore, did)
.iter()
.filter_map(|did| {
let did = did.def_id();
let impl_item = ty::impl_or_trait_item(tcx, did);
let impl_item = tcx.impl_or_trait_item(did);
match impl_item {
ty::ConstTraitItem(ref assoc_const) => {
let did = assoc_const.def_id;
let type_scheme = ty::lookup_item_type(tcx, did);
let type_scheme = tcx.lookup_item_type(did);
let default = match assoc_const.default {
Some(_) => Some(const_eval::lookup_const_by_id(tcx, did, None)
.unwrap().span.to_src(cx)),
@ -383,7 +383,7 @@ pub fn build_impl(cx: &DocContext,
}
}).collect::<Vec<_>>();
let polarity = csearch::get_impl_polarity(tcx, did);
let ty = ty::lookup_item_type(tcx, did);
let ty = tcx.lookup_item_type(did);
let trait_ = associated_trait.clean(cx).map(|bound| {
match bound {
clean::TraitBound(polyt, _) => polyt.trait_,
@ -477,7 +477,7 @@ fn build_const(cx: &DocContext, tcx: &ty::ctxt,
debug!("got snippet {}", sn);
clean::Constant {
type_: ty::lookup_item_type(tcx, did).ty.clean(cx),
type_: tcx.lookup_item_type(did).ty.clean(cx),
expr: sn
}
}
@ -486,7 +486,7 @@ fn build_static(cx: &DocContext, tcx: &ty::ctxt,
did: ast::DefId,
mutable: bool) -> clean::Static {
clean::Static {
type_: ty::lookup_item_type(tcx, did).ty.clean(cx),
type_: tcx.lookup_item_type(did).ty.clean(cx),
mutability: if mutable {clean::Mutable} else {clean::Immutable},
expr: "\n\n\n".to_string(), // trigger the "[definition]" links
}

View file

@ -1332,7 +1332,7 @@ impl<'tcx> Clean<Item> for ty::Method<'tcx> {
let provided = match self.container {
ty::ImplContainer(..) => false,
ty::TraitContainer(did) => {
ty::provided_trait_methods(cx.tcx(), did).iter().any(|m| {
cx.tcx().provided_trait_methods(did).iter().any(|m| {
m.def_id == self.def_id
})
}
@ -1742,7 +1742,7 @@ impl Clean<Item> for ty::field_ty {
(Some(self.name), Some(attr_map.get(&self.id.node).unwrap()))
};
let ty = ty::lookup_item_type(cx.tcx(), self.id);
let ty = cx.tcx().lookup_item_type(self.id);
Item {
name: name.clean(cx),
@ -2731,8 +2731,8 @@ impl<'tcx> Clean<Item> for ty::AssociatedType<'tcx> {
// 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
// applied to this associated type in question.
let def = ty::lookup_trait_def(cx.tcx(), did);
let predicates = ty::lookup_predicates(cx.tcx(), did);
let def = cx.tcx().lookup_trait_def(did);
let predicates = cx.tcx().lookup_predicates(did);
let generics = (&def.generics, &predicates, subst::TypeSpace).clean(cx);
generics.where_predicates.iter().filter_map(|pred| {
let (name, self_type, trait_, bounds) = match *pred {

View file

@ -30,7 +30,6 @@ use std::mem;
use std::collections::HashMap;
use rustc::middle::subst;
use rustc::middle::ty;
use syntax::ast;
use clean::PathParameters as PP;
@ -154,8 +153,8 @@ fn trait_is_same_or_supertrait(cx: &DocContext, child: ast::DefId,
if child == trait_ {
return true
}
let def = ty::lookup_trait_def(cx.tcx(), child);
let predicates = ty::lookup_predicates(cx.tcx(), child);
let def = cx.tcx().lookup_trait_def(child);
let predicates = cx.tcx().lookup_predicates(child);
let generics = (&def.generics, &predicates, subst::TypeSpace).clean(cx);
generics.where_predicates.iter().filter_map(|pred| {
match *pred {