}
hir::ExprIndex(ref l, ref r) |
- hir::ExprBinary(_, ref l, ref r) if self.tcx.is_method_call(expr.id) => {
+ hir::ExprBinary(_, ref l, ref r) if self.tcx.tables().is_method_call(expr.id) => {
self.call(expr, pred, &l, Some(&**r).into_iter())
}
- hir::ExprUnary(_, ref e) if self.tcx.is_method_call(expr.id) => {
+ hir::ExprUnary(_, ref e) if self.tcx.tables().is_method_call(expr.id) => {
self.call(expr, pred, &e, None::<hir::Expr>.iter())
}
func_or_rcvr: &hir::Expr,
args: I) -> CFGIndex {
let method_call = ty::MethodCall::expr(call_expr.id);
- let fn_ty = match self.tcx.tables.borrow().method_map.get(&method_call) {
+ let fn_ty = match self.tcx.tables().method_map.get(&method_call) {
Some(method) => method.ty,
None => self.tcx.expr_ty_adjusted(func_or_rcvr)
};
match def {
Def::AssociatedTy(..) | Def::Method(_) | Def::AssociatedConst(_)
if self.tcx.trait_of_item(def.def_id()).is_some() => {
- if let Some(substs) = self.tcx.tables.borrow().item_substs.get(&id) {
+ if let Some(substs) = self.tcx.tables().item_substs.get(&id) {
if let ty::TyAdt(tyid, _) = substs.substs.type_at(0).sty {
self.check_def_id(tyid.did);
}
fn lookup_and_handle_method(&mut self, id: ast::NodeId) {
let method_call = ty::MethodCall::expr(id);
- let method = self.tcx.tables.borrow().method_map[&method_call];
+ let method = self.tcx.tables().method_map[&method_call];
self.check_def_id(method.def_id);
}
fn handle_field_pattern_match(&mut self, lhs: &hir::Pat,
pats: &[codemap::Spanned<hir::FieldPat>]) {
- let variant = match self.tcx.node_id_to_type(lhs.id).sty {
+ let variant = match self.tcx.tables().node_id_to_type(lhs.id).sty {
ty::TyAdt(adt, _) => {
adt.variant_of_def(self.tcx.expect_def(lhs.id))
}
}
fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool {
- let field_type = self.tcx.node_id_to_type(field.id);
+ let field_type = self.tcx.tables().node_id_to_type(field.id);
let is_marker_field = match field_type.ty_to_def_id() {
Some(def_id) => self.tcx.lang_items.items().iter().any(|item| *item == Some(def_id)),
_ => false
match expr.node {
hir::ExprMethodCall(..) => {
let method_call = MethodCall::expr(expr.id);
- let base_type = self.tcx.tables.borrow().method_map[&method_call].ty;
+ let base_type = self.tcx.tables().method_map[&method_call].ty;
debug!("effect: method call case, base type is {:?}",
base_type);
if type_is_unsafe_function(base_type) {
fn visit_pat(&mut self, pat: &hir::Pat) {
if let PatKind::Struct(_, ref fields, _) = pat.node {
- if let ty::TyAdt(adt, ..) = self.tcx.pat_ty(pat).sty {
+ if let ty::TyAdt(adt, ..) = self.tcx.tables().pat_ty(pat).sty {
if adt.is_union() {
for field in fields {
self.require_unsafe(field.span, "matching on union field");
if let hir::ExprPath(..) = expr.node {
match self.infcx.tcx.expect_def(expr.id) {
Def::Fn(did) if self.def_id_is_transmute(did) => {
- let typ = self.infcx.tcx.node_id_to_type(expr.id);
+ let typ = self.infcx.tcx.tables().node_id_to_type(expr.id);
match typ.sty {
ty::TyFnDef(.., ref bare_fn_ty) if bare_fn_ty.abi == RustIntrinsic => {
let from = bare_fn_ty.sig.0.inputs[0];
hir::ExprAssignOp(_, ref l, ref r) => {
// an overloaded assign op is like a method call
- if self.ir.tcx.is_method_call(expr.id) {
+ if self.ir.tcx.tables().is_method_call(expr.id) {
let succ = self.propagate_through_expr(&l, succ);
self.propagate_through_expr(&r, succ)
} else {
hir::ExprCall(ref f, ref args) => {
// FIXME(canndrew): This is_never should really be an is_uninhabited
- let diverges = !self.ir.tcx.is_method_call(expr.id) &&
+ let diverges = !self.ir.tcx.tables().is_method_call(expr.id) &&
self.ir.tcx.expr_ty_adjusted(&f).fn_ret().0.is_never();
let succ = if diverges {
self.s.exit_ln
hir::ExprMethodCall(.., ref args) => {
let method_call = ty::MethodCall::expr(expr.id);
- let method_ty = self.ir.tcx.tables.borrow().method_map[&method_call].ty;
+ let method_ty = self.ir.tcx.tables().method_map[&method_call].ty;
// FIXME(canndrew): This is_never should really be an is_uninhabited
let succ = if method_ty.fn_ret().0.is_never() {
self.s.exit_ln
}
hir::ExprAssignOp(_, ref l, _) => {
- if !this.ir.tcx.is_method_call(expr.id) {
+ if !this.ir.tcx.tables().is_method_call(expr.id) {
this.check_lvalue(&l);
}
impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn fn_ret(&self, id: NodeId) -> ty::Binder<Ty<'tcx>> {
- let fn_ty = self.ir.tcx.node_id_to_type(id);
+ let fn_ty = self.ir.tcx.tables().node_id_to_type(id);
match fn_ty.sty {
ty::TyClosure(closure_def_id, substs) =>
self.ir.tcx.closure_type(closure_def_id, substs).sig.output(),
None if !body.stmts.is_empty() =>
match body.stmts.last().unwrap().node {
hir::StmtSemi(ref e, _) => {
- self.ir.tcx.expr_ty(&e) == fn_ret
+ self.ir.tcx.tables().expr_ty(&e) == fn_ret
},
_ => false
},
}
hir::ExprMethodCall(..) => {
let method_call = ty::MethodCall::expr(expr.id);
- let def_id = self.tcx.tables.borrow().method_map[&method_call].def_id;
+ let def_id = self.tcx.tables().method_map[&method_call].def_id;
// Mark the trait item (and, possibly, its default impl) as reachable
// Or mark inherent impl item as reachable
hir::ExprMethodCall(i, ..) => {
span = i.span;
let method_call = ty::MethodCall::expr(e.id);
- tcx.tables.borrow().method_map[&method_call].def_id
+ tcx.tables().method_map[&method_call].def_id
}
hir::ExprField(ref base_e, ref field) => {
span = field.span;
}
}
hir::ExprStruct(_, ref expr_fields, _) => {
- match tcx.expr_ty(e).sty {
+ match tcx.tables().expr_ty(e).sty {
ty::TyAdt(adt, ..) => match adt.adt_kind() {
AdtKind::Struct | AdtKind::Union => {
// check the stability of each field that appears
debug!("check_pat(pat = {:?})", pat);
if is_internal(tcx, pat.span) { return; }
- let v = match tcx.pat_ty_opt(pat).map(|ty| &ty.sty) {
+ let v = match tcx.tables().pat_ty_opt(pat).map(|ty| &ty.sty) {
Some(&ty::TyAdt(adt, _)) if !adt.is_enum() => adt.struct_variant(),
_ => return,
};
use arena::TypedArena;
use std::borrow::Borrow;
-use std::cell::{Cell, RefCell, Ref};
+use std::cell::{Cell, RefCell};
use std::hash::{Hash, Hasher};
use std::mem;
use std::ops::Deref;
fru_field_types: NodeMap()
}
}
+
+ pub fn node_id_to_type(&self, id: NodeId) -> Ty<'tcx> {
+ match self.node_id_to_type_opt(id) {
+ Some(ty) => ty,
+ None => {
+ bug!("node_id_to_type: no type for node `{}`",
+ tls::with(|tcx| tcx.map.node_to_string(id)))
+ }
+ }
+ }
+
+ pub fn node_id_to_type_opt(&self, id: NodeId) -> Option<Ty<'tcx>> {
+ self.node_types.get(&id).cloned()
+ }
+
+ pub fn node_id_item_substs(&self, id: NodeId) -> Option<&'tcx Substs<'tcx>> {
+ self.item_substs.get(&id).map(|ts| ts.substs)
+ }
+
+ // Returns the type of a pattern as a monotype. Like @expr_ty, this function
+ // doesn't provide type parameter substitutions.
+ pub fn pat_ty(&self, pat: &hir::Pat) -> Ty<'tcx> {
+ self.node_id_to_type(pat.id)
+ }
+
+ pub fn pat_ty_opt(&self, pat: &hir::Pat) -> Option<Ty<'tcx>> {
+ self.node_id_to_type_opt(pat.id)
+ }
+
+ // Returns the type of an expression as a monotype.
+ //
+ // NB (1): This is the PRE-ADJUSTMENT TYPE for the expression. That is, in
+ // some cases, we insert `AutoAdjustment` annotations such as auto-deref or
+ // auto-ref. The type returned by this function does not consider such
+ // adjustments. See `expr_ty_adjusted()` instead.
+ //
+ // NB (2): This type doesn't provide type parameter substitutions; e.g. if you
+ // ask for the type of "id" in "id(3)", it will return "fn(&isize) -> isize"
+ // instead of "fn(ty) -> T with T = isize".
+ pub fn expr_ty(&self, expr: &hir::Expr) -> Ty<'tcx> {
+ self.node_id_to_type(expr.id)
+ }
+
+ pub fn expr_ty_opt(&self, expr: &hir::Expr) -> Option<Ty<'tcx>> {
+ self.node_id_to_type_opt(expr.id)
+ }
+
+
+ pub fn is_method_call(&self, expr_id: NodeId) -> bool {
+ self.method_map.contains_key(&ty::MethodCall::expr(expr_id))
+ }
+
+ pub fn is_overloaded_autoderef(&self, expr_id: NodeId, autoderefs: u32) -> bool {
+ self.method_map.contains_key(&ty::MethodCall::autoderef(expr_id, autoderefs))
+ }
+
+ pub fn upvar_capture(&self, upvar_id: ty::UpvarId) -> Option<ty::UpvarCapture<'tcx>> {
+ Some(self.upvar_capture_map.get(&upvar_id).unwrap().clone())
+ }
}
impl<'tcx> CommonTypes<'tcx> {
self.ty_param_defs.borrow().get(&node_id).unwrap().clone()
}
- pub fn node_types(self) -> Ref<'a, NodeMap<Ty<'tcx>>> {
- fn projection<'a, 'tcx>(tables: &'a Tables<'tcx>) -> &'a NodeMap<Ty<'tcx>> {
- &tables.node_types
- }
-
- Ref::map(self.tables.borrow(), projection)
- }
-
pub fn node_type_insert(self, id: NodeId, ty: Ty<'gcx>) {
self.tables.borrow_mut().node_types.insert(id, ty);
}
}
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
- pub fn node_id_to_type(self, id: NodeId) -> Ty<'gcx> {
- match self.node_id_to_type_opt(id) {
- Some(ty) => ty,
- None => bug!("node_id_to_type: no type for node `{}`",
- self.map.node_to_string(id))
- }
- }
-
- pub fn node_id_to_type_opt(self, id: NodeId) -> Option<Ty<'gcx>> {
- self.tables.borrow().node_types.get(&id).cloned()
- }
-
- pub fn node_id_item_substs(self, id: NodeId) -> ItemSubsts<'gcx> {
- match self.tables.borrow().item_substs.get(&id) {
- None => ItemSubsts {
- substs: self.global_tcx().intern_substs(&[])
- },
- Some(ts) => ts.clone(),
- }
- }
-
- // Returns the type of a pattern as a monotype. Like @expr_ty, this function
- // doesn't provide type parameter substitutions.
- pub fn pat_ty(self, pat: &hir::Pat) -> Ty<'gcx> {
- self.node_id_to_type(pat.id)
- }
- pub fn pat_ty_opt(self, pat: &hir::Pat) -> Option<Ty<'gcx>> {
- self.node_id_to_type_opt(pat.id)
- }
-
- // Returns the type of an expression as a monotype.
- //
- // NB (1): This is the PRE-ADJUSTMENT TYPE for the expression. That is, in
- // some cases, we insert `AutoAdjustment` annotations such as auto-deref or
- // auto-ref. The type returned by this function does not consider such
- // adjustments. See `expr_ty_adjusted()` instead.
- //
- // NB (2): This type doesn't provide type parameter substitutions; e.g. if you
- // ask for the type of "id" in "id(3)", it will return "fn(&isize) -> isize"
- // instead of "fn(ty) -> T with T = isize".
- pub fn expr_ty(self, expr: &hir::Expr) -> Ty<'gcx> {
- self.node_id_to_type(expr.id)
- }
-
- pub fn expr_ty_opt(self, expr: &hir::Expr) -> Option<Ty<'gcx>> {
- self.node_id_to_type_opt(expr.id)
+ pub fn tables(self) -> Ref<'a, Tables<'gcx>> {
+ self.tables.borrow()
}
/// Returns the type of `expr`, considering any `AutoAdjustment`
/// unless it was to fix it properly, which seemed a distraction from the
/// thread at hand! -nmatsakis
pub fn expr_ty_adjusted(self, expr: &hir::Expr) -> Ty<'gcx> {
- self.expr_ty(expr)
+ self.tables().expr_ty(expr)
.adjust(self.global_tcx(), expr.span, expr.id,
- self.tables.borrow().adjustments.get(&expr.id),
+ self.tables().adjustments.get(&expr.id),
|method_call| {
- self.tables.borrow().method_map.get(&method_call).map(|method| method.ty)
+ self.tables().method_map.get(&method_call).map(|method| method.ty)
})
}
pub fn expr_ty_adjusted_opt(self, expr: &hir::Expr) -> Option<Ty<'gcx>> {
- self.expr_ty_opt(expr).map(|t| t.adjust(self.global_tcx(),
+ self.tables().expr_ty_opt(expr).map(|t| t.adjust(self.global_tcx(),
expr.span,
expr.id,
- self.tables.borrow().adjustments.get(&expr.id),
+ self.tables().adjustments.get(&expr.id),
|method_call| {
- self.tables.borrow().method_map.get(&method_call).map(|method| method.ty)
+ self.tables().method_map.get(&method_call).map(|method| method.ty)
}))
}
self.mk_region(ty::ReScope(self.region_maps.node_extent(id)))
}
- pub fn is_method_call(self, expr_id: NodeId) -> bool {
- self.tables.borrow().method_map.contains_key(&MethodCall::expr(expr_id))
- }
-
- pub fn is_overloaded_autoderef(self, expr_id: NodeId, autoderefs: u32) -> bool {
- self.tables.borrow().method_map.contains_key(&MethodCall::autoderef(expr_id,
- autoderefs))
- }
-
- pub fn upvar_capture(self, upvar_id: ty::UpvarId) -> Option<ty::UpvarCapture<'tcx>> {
- Some(self.tables.borrow().upvar_capture_map.get(&upvar_id).unwrap().clone())
- }
-
pub fn visit_all_items_in_krate<V,F>(self,
dep_node_fn: F,
visitor: &mut V)
decl_id: ast::NodeId,
_decl_span: Span,
var_id: ast::NodeId) {
- let ty = bccx.tcx.node_id_to_type(var_id);
+ let ty = bccx.tcx.tables().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);
}
// Finally, check if the whole match expression is exhaustive.
// Check for empty enum, because is_useful only works on inhabited types.
- let pat_ty = self.tcx.node_id_to_type(scrut.id);
+ let pat_ty = self.tcx.tables().node_id_to_type(scrut.id);
if inlined_arms.is_empty() {
if !pat_ty.is_uninhabited(self.tcx) {
// We know the type is inhabited, so this must be wrong
fn check_for_bindings_named_the_same_as_variants(cx: &MatchVisitor, pat: &Pat) {
pat.walk(|p| {
if let PatKind::Binding(hir::BindByValue(hir::MutImmutable), name, None) = p.node {
- let pat_ty = cx.tcx.pat_ty(p);
+ let pat_ty = cx.tcx.tables().pat_ty(p);
if let ty::TyAdt(edef, _) = pat_ty.sty {
if edef.is_enum() {
if let Def::Local(..) = cx.tcx.expect_def(p.id) {
for pat in pats {
pat.walk(|p| {
if let PatKind::Binding(hir::BindByValue(..), _, ref sub) = p.node {
- let pat_ty = cx.tcx.node_id_to_type(p.id);
+ let pat_ty = cx.tcx.tables().node_id_to_type(p.id);
if pat_ty.moves_by_default(cx.tcx, cx.param_env, pat.span) {
check_move(p, sub.as_ref().map(|p| &**p));
}
pat_id: ast::NodeId,
span: Span)
-> Result<P<hir::Pat>, DefId> {
- let pat_ty = tcx.expr_ty(expr);
+ let pat_ty = tcx.tables().expr_ty(expr);
debug!("expr={:?} pat_ty={:?} pat_id={}", expr, pat_ty, pat_id);
match pat_ty.sty {
ty::TyFloat(_) => {
Def::StructCtor(_, CtorKind::Const) |
Def::VariantCtor(_, CtorKind::Const) => PatKind::Path(None, path.clone()),
Def::Const(def_id) | Def::AssociatedConst(def_id) => {
- let substs = Some(tcx.node_id_item_substs(expr.id).substs);
+ let substs = Some(tcx.tables().node_id_item_substs(expr.id)
+ .unwrap_or_else(|| tcx.intern_substs(&[])));
let (expr, _ty) = lookup_const_by_id(tcx, def_id, substs).unwrap();
return const_expr_to_pat(tcx, expr, pat_id, span);
},
let ety = match ty_hint {
ExprTypeChecked => {
// After type-checking, expr_ty is guaranteed to succeed.
- Some(tcx.expr_ty(e))
+ Some(tcx.tables().expr_ty(e))
}
UncheckedExprHint(ty) => {
// Use the type hint; it's not guaranteed to be right, but it's
// This expression might not be type-checked, and we have no hint.
// Try to query the context for a type anyway; we might get lucky
// (for example, if the expression was imported from another crate).
- tcx.expr_ty_opt(e)
+ tcx.tables().expr_ty_opt(e)
}
};
let result = match e.node {
let base_hint = if let ExprTypeChecked = ty_hint {
ExprTypeChecked
} else {
- match tcx.expr_ty_opt(&base) {
+ match tcx.tables().expr_ty_opt(&base) {
Some(t) => UncheckedExprHint(t),
None => ty_hint
}
Def::Const(def_id) |
Def::AssociatedConst(def_id) => {
let substs = if let ExprTypeChecked = ty_hint {
- Some(tcx.node_id_item_substs(e.id).substs)
+ Some(tcx.tables().node_id_item_substs(e.id)
+ .unwrap_or_else(|| tcx.intern_substs(&[])))
} else {
None
};
}
pub fn lower_pattern(&mut self, pat: &hir::Pat) -> Pattern<'tcx> {
- let mut ty = self.tcx.node_id_to_type(pat.id);
+ let mut ty = self.tcx.tables().node_id_to_type(pat.id);
let kind = match pat.node {
PatKind::Wild => PatternKind::Wild,
match self.tcx.expect_def(pat.id) {
Def::Const(def_id) | Def::AssociatedConst(def_id) => {
let tcx = self.tcx.global_tcx();
- let substs = Some(self.tcx.node_id_item_substs(pat.id).substs);
- match eval::lookup_const_by_id(tcx, def_id, substs) {
+ let substs = tcx.tables().node_id_item_substs(pat.id)
+ .unwrap_or_else(|| tcx.intern_substs(&[]));
+ match eval::lookup_const_by_id(tcx, def_id, Some(substs)) {
Some((const_expr, _const_ty)) => {
match eval::const_expr_to_pat(
tcx, const_expr, pat.id, pat.span)
}
PatKind::Slice(ref prefix, ref slice, ref suffix) => {
- let ty = self.tcx.node_id_to_type(pat.id);
+ let ty = self.tcx.tables().node_id_to_type(pat.id);
match ty.sty {
ty::TyRef(_, mt) =>
PatternKind::Deref {
}
PatKind::Tuple(ref subpatterns, ddpos) => {
- match self.tcx.node_id_to_type(pat.id).sty {
+ match self.tcx.tables().node_id_to_type(pat.id).sty {
ty::TyTuple(ref tys) => {
let subpatterns =
subpatterns.iter()
PatKind::Binding(bm, ref ident, ref sub) => {
let def_id = self.tcx.expect_def(pat.id).def_id();
let id = self.tcx.map.as_local_node_id(def_id).unwrap();
- let var_ty = self.tcx.node_id_to_type(pat.id);
+ let var_ty = self.tcx.tables().node_id_to_type(pat.id);
let region = match var_ty.sty {
ty::TyRef(r, _) => Some(r),
_ => None,
}
PatKind::TupleStruct(_, ref subpatterns, ddpos) => {
- let pat_ty = self.tcx.node_id_to_type(pat.id);
+ let pat_ty = self.tcx.tables().node_id_to_type(pat.id);
let adt_def = match pat_ty.sty {
ty::TyAdt(adt_def, _) => adt_def,
_ => span_bug!(pat.span, "tuple struct pattern not applied to an ADT"),
}
PatKind::Struct(_, ref fields, _) => {
- let pat_ty = self.tcx.node_id_to_type(pat.id);
+ let pat_ty = self.tcx.tables().node_id_to_type(pat.id);
let adt_def = match pat_ty.sty {
ty::TyAdt(adt_def, _) => adt_def,
_ => {
pp::space(&mut s.s)?;
pp::word(&mut s.s, "as")?;
pp::space(&mut s.s)?;
- pp::word(&mut s.s, &self.tcx.expr_ty(expr).to_string())?;
+ pp::word(&mut s.s, &self.tcx.tables().expr_ty(expr).to_string())?;
s.pclose()
}
_ => Ok(()),
hir::ItemTy(..) |
hir::ItemEnum(..) |
hir::ItemStruct(..) |
- hir::ItemUnion(..) => self.check_heap_type(cx, it.span, cx.tcx.node_id_to_type(it.id)),
+ hir::ItemUnion(..) => {
+ self.check_heap_type(cx, it.span, cx.tcx.tables().node_id_to_type(it.id))
+ }
_ => (),
}
for struct_field in struct_def.fields() {
self.check_heap_type(cx,
struct_field.span,
- cx.tcx.node_id_to_type(struct_field.id));
+ cx.tcx.tables().node_id_to_type(struct_field.id));
}
}
_ => (),
}
fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
- let ty = cx.tcx.node_id_to_type(e.id);
+ let ty = cx.tcx.tables().node_id_to_type(e.id);
self.check_heap_type(cx, e.span, ty);
}
}
let mut impls = NodeSet();
debug_def.for_each_impl(cx.tcx, |d| {
if let Some(n) = cx.tcx.map.as_local_node_id(d) {
- if let Some(ty_def) = cx.tcx.node_id_to_type(n).ty_to_def_id() {
+ if let Some(ty_def) = cx.tcx.tables().node_id_to_type(n).ty_to_def_id() {
if let Some(node_id) = cx.tcx.map.as_local_node_id(ty_def) {
impls.insert(node_id);
}
id: ast::NodeId)
-> bool {
// Check for method calls and overloaded operators.
- let opt_m = tcx.tables.borrow().method_map.get(&ty::MethodCall::expr(id)).cloned();
+ let opt_m = tcx.tables().method_map.get(&ty::MethodCall::expr(id)).cloned();
if let Some(m) = opt_m {
if method_call_refers_to_method(tcx, method, m.def_id, m.substs, id) {
return true;
}
// Check for overloaded autoderef method calls.
- let opt_adj = tcx.tables.borrow().adjustments.get(&id).cloned();
+ let opt_adj = tcx.tables().adjustments.get(&id).cloned();
if let Some(adjustment::AdjustDerefRef(adj)) = opt_adj {
for i in 0..adj.autoderefs {
let method_call = ty::MethodCall::autoderef(id, i as u32);
- if let Some(m) = tcx.tables
- .borrow()
- .method_map
- .get(&method_call)
- .cloned() {
+ if let Some(m) = tcx.tables().method_map.get(&method_call)
+ .cloned() {
if method_call_refers_to_method(tcx, method, m.def_id, m.substs, id) {
return true;
}
// it doesn't necessarily have a definition.
match tcx.expect_def_or_none(callee.id) {
Some(Def::Method(def_id)) => {
- let item_substs = tcx.node_id_item_substs(callee.id);
- method_call_refers_to_method(tcx,
- method,
- def_id,
- &item_substs.substs,
- id)
+ let substs = tcx.tables().node_id_item_substs(callee.id)
+ .unwrap_or_else(|| tcx.intern_substs(&[]));
+ method_call_refers_to_method(
+ tcx, method, def_id, substs, id)
}
_ => false,
}
if !def_id_is_transmute(cx, did) {
return None;
}
- let typ = cx.tcx.node_id_to_type(expr.id);
+ let typ = cx.tcx.tables().node_id_to_type(expr.id);
match typ.sty {
ty::TyFnDef(.., ref bare_fn) if bare_fn.abi == RustIntrinsic => {
let from = bare_fn.sig.0.inputs[0];
if let hir::ItemUnion(ref vdata, _) = item.node {
let param_env = &ty::ParameterEnvironment::for_item(ctx.tcx, item.id);
for field in vdata.fields() {
- let field_ty = ctx.tcx.node_id_to_type(field.id);
+ let field_ty = ctx.tcx.tables().node_id_to_type(field.id);
if ctx.tcx.type_needs_drop_given_env(field_ty, param_env) {
ctx.span_lint(UNIONS_WITH_DROP_FIELDS,
field.span,
forbid_unsigned_negation(cx, e.span);
}
ast::LitKind::Int(_, ast::LitIntType::Unsuffixed) => {
- if let ty::TyUint(_) = cx.tcx.node_id_to_type(e.id).sty {
+ if let ty::TyUint(_) = cx.tcx.tables().node_id_to_type(e.id).sty {
forbid_unsigned_negation(cx, e.span);
}
}
_ => (),
}
} else {
- let t = cx.tcx.node_id_to_type(expr.id);
+ let t = cx.tcx.tables().node_id_to_type(expr.id);
if let ty::TyUint(_) = t.sty {
forbid_unsigned_negation(cx, e.span);
}
}
if binop.node.is_shift() {
- let opt_ty_bits = match cx.tcx.node_id_to_type(l.id).sty {
+ let opt_ty_bits = match cx.tcx.tables().node_id_to_type(l.id).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,
}
}
hir::ExprLit(ref lit) => {
- match cx.tcx.node_id_to_type(e.id).sty {
+ match cx.tcx.tables().node_id_to_type(e.id).sty {
ty::TyInt(t) => {
match lit.node {
ast::LitKind::Int(v, ast::LitIntType::Signed(_)) |
// Normalize the binop so that the literal is always on the RHS in
// the comparison
let norm_binop = if swap { rev_binop(binop) } else { binop };
- match tcx.node_id_to_type(expr.id).sty {
+ match tcx.tables().node_id_to_type(expr.id).sty {
ty::TyInt(int_ty) => {
let (min, max) = int_ty_range(int_ty);
let lit_val: i64 = match lit.node {
if let hir::ItemEnum(ref enum_definition, ref gens) = it.node {
if gens.ty_params.is_empty() {
// sizes only make sense for non-generic types
- let t = cx.tcx.node_id_to_type(it.id);
+ let t = cx.tcx.tables().node_id_to_type(it.id);
let layout = cx.tcx.infer_ctxt(None, None, Reveal::All).enter(|infcx| {
let ty = cx.tcx.erase_regions(&t);
ty.layout(&infcx)
return;
}
- let t = cx.tcx.expr_ty(&expr);
+ let t = cx.tcx.tables().expr_ty(&expr);
let warned = match t.sty {
ty::TyTuple(ref tys) if tys.is_empty() => return,
ty::TyNever => return,
_ => return,
}
- if let Some(adjustment) = cx.tcx.tables.borrow().adjustments.get(&e.id) {
+ if let Some(adjustment) = cx.tcx.tables().adjustments.get(&e.id) {
if let adjustment::AdjustDerefRef(adjustment::AutoDerefRef { ref autoref, .. }) =
*adjustment {
match autoref {
};
encode(tcx.expect_def_or_none(id).map(TableEntry::Def));
- encode(tcx.node_types().get(&id).cloned().map(TableEntry::NodeType));
- encode(tcx.tables.borrow().item_substs.get(&id).cloned().map(TableEntry::ItemSubsts));
- encode(tcx.tables.borrow().adjustments.get(&id).cloned().map(TableEntry::Adjustment));
+ encode(tcx.tables().node_types.get(&id).cloned().map(TableEntry::NodeType));
+ encode(tcx.tables().item_substs.get(&id).cloned().map(TableEntry::ItemSubsts));
+ encode(tcx.tables().adjustments.get(&id).cloned().map(TableEntry::Adjustment));
encode(tcx.const_qualif_map.borrow().get(&id).cloned().map(TableEntry::ConstQualif));
}
}
let data = ClosureData {
kind: tcx.closure_kind(def_id),
- ty: self.lazy(&tcx.tables.borrow().closure_tys[&def_id]),
+ ty: self.lazy(&tcx.tables().closure_tys[&def_id]),
};
Entry {
assert_eq!(block, builder.return_block());
let mut spread_arg = None;
- match tcx.node_id_to_type(fn_id).sty {
+ match tcx.tables().node_id_to_type(fn_id).sty {
ty::TyFnDef(_, _, f) if f.abi == Abi::RustCall => {
// RustCall pseudo-ABI untuples the last argument.
spread_arg = Some(Local::new(arguments.len()));
let upvar_decls: Vec<_> = tcx.with_freevars(fn_id, |freevars| {
freevars.iter().map(|fv| {
let var_id = tcx.map.as_local_node_id(fv.def.def_id()).unwrap();
- let by_ref = tcx.upvar_capture(ty::UpvarId {
+ let by_ref = tcx.tables().upvar_capture(ty::UpvarId {
var_id: var_id,
closure_expr_id: fn_id
}).map_or(false, |capture| match capture {
pub fn to_expr_ref<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
block: &'tcx hir::Block)
-> ExprRef<'tcx> {
- let block_ty = cx.tcx.node_id_to_type(block.id);
+ let block_ty = cx.tcx.tables().node_id_to_type(block.id);
let temp_lifetime = cx.tcx.region_maps.temporary_scope(block.id);
let expr = Expr {
ty: block_ty,
let mut expr = make_mirror_unadjusted(cx, self);
debug!("make_mirror: unadjusted-expr={:?} applying adjustments={:?}",
- expr, cx.tcx.tables.borrow().adjustments.get(&self.id));
+ expr, cx.tcx.tables().adjustments.get(&self.id));
// Now apply adjustments, if any.
- match cx.tcx.tables.borrow().adjustments.get(&self.id) {
+ match cx.tcx.tables().adjustments.get(&self.id) {
None => {}
Some(&ty::adjustment::AdjustReifyFnPointer) => {
let adjusted_ty = cx.tcx.expr_ty_adjusted(self);
self.id,
self.span,
i,
- |mc| cx.tcx.tables.borrow().method_map.get(&mc).map(|m| m.ty));
+ |mc| cx.tcx.tables().method_map.get(&mc).map(|m| m.ty));
debug!("make_mirror: autoderef #{}, adjusted_ty={:?}", i, adjusted_ty);
let method_key = ty::MethodCall::autoderef(self.id, i);
let meth_ty =
- cx.tcx.tables.borrow().method_map.get(&method_key).map(|m| m.ty);
+ cx.tcx.tables().method_map.get(&method_key).map(|m| m.ty);
let kind = if let Some(meth_ty) = meth_ty {
debug!("make_mirror: overloaded autoderef (meth_ty={:?})", meth_ty);
fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
expr: &'tcx hir::Expr)
-> Expr<'tcx> {
- let expr_ty = cx.tcx.expr_ty(expr);
+ let expr_ty = cx.tcx.tables().expr_ty(expr);
let temp_lifetime = cx.tcx.region_maps.temporary_scope(expr.id);
let kind = match expr.node {
}
hir::ExprCall(ref fun, ref args) => {
- if cx.tcx.is_method_call(expr.id) {
+ if cx.tcx.tables().is_method_call(expr.id) {
// The callee is something implementing Fn, FnMut, or FnOnce.
// Find the actual method implementation being called and
// build the appropriate UFCS call expression with the
})
} else { None };
if let Some((adt_def, index)) = adt_data {
- let substs = cx.tcx.node_id_item_substs(fun.id).substs;
+ let substs = cx.tcx.tables().node_id_item_substs(fun.id)
+ .unwrap_or_else(|| cx.tcx.intern_substs(&[]));
let field_refs = args.iter().enumerate().map(|(idx, e)| FieldExprRef {
name: Field::new(idx),
expr: e.to_ref()
}
} else {
ExprKind::Call {
- ty: cx.tcx.node_id_to_type(fun.id),
+ ty: cx.tcx.tables().node_id_to_type(fun.id),
fun: fun.to_ref(),
args: args.to_ref(),
}
}
hir::ExprAssignOp(op, ref lhs, ref rhs) => {
- if cx.tcx.is_method_call(expr.id) {
+ if cx.tcx.tables().is_method_call(expr.id) {
let pass_args = if op.node.is_by_value() {
PassArgs::ByValue
} else {
},
hir::ExprBinary(op, ref lhs, ref rhs) => {
- if cx.tcx.is_method_call(expr.id) {
+ if cx.tcx.tables().is_method_call(expr.id) {
let pass_args = if op.node.is_by_value() {
PassArgs::ByValue
} else {
}
hir::ExprIndex(ref lhs, ref index) => {
- if cx.tcx.is_method_call(expr.id) {
+ if cx.tcx.tables().is_method_call(expr.id) {
overloaded_lvalue(cx, expr, ty::MethodCall::expr(expr.id),
PassArgs::ByValue, lhs.to_ref(), vec![index])
} else {
}
hir::ExprUnary(hir::UnOp::UnDeref, ref arg) => {
- if cx.tcx.is_method_call(expr.id) {
+ if cx.tcx.tables().is_method_call(expr.id) {
overloaded_lvalue(cx, expr, ty::MethodCall::expr(expr.id),
PassArgs::ByValue, arg.to_ref(), vec![])
} else {
}
hir::ExprUnary(hir::UnOp::UnNot, ref arg) => {
- if cx.tcx.is_method_call(expr.id) {
+ if cx.tcx.tables().is_method_call(expr.id) {
overloaded_operator(cx, expr, ty::MethodCall::expr(expr.id),
PassArgs::ByValue, arg.to_ref(), vec![])
} else {
}
hir::ExprUnary(hir::UnOp::UnNeg, ref arg) => {
- if cx.tcx.is_method_call(expr.id) {
+ if cx.tcx.tables().is_method_call(expr.id) {
overloaded_operator(cx, expr, ty::MethodCall::expr(expr.id),
PassArgs::ByValue, arg.to_ref(), vec![])
} else {
base: base.as_ref().map(|base| {
FruInfo {
base: base.to_ref(),
- field_types: cx.tcx.tables
- .borrow()
- .fru_field_types[&expr.id]
- .clone()
+ field_types:
+ cx.tcx.tables().fru_field_types[&expr.id].clone()
}
})
}
}
hir::ExprClosure(..) => {
- let closure_ty = cx.tcx.expr_ty(expr);
+ let closure_ty = cx.tcx.tables().expr_ty(expr);
let (def_id, substs) = match closure_ty.sty {
ty::TyClosure(def_id, substs) => (def_id, substs),
_ => {
hir::ExprRepeat(ref v, ref c) => ExprKind::Repeat {
value: v.to_ref(),
count: TypedConstVal {
- ty: cx.tcx.expr_ty(c),
+ ty: cx.tcx.tables().expr_ty(c),
span: c.span,
value: match const_eval::eval_const_expr(cx.tcx.global_tcx(), c) {
ConstVal::Integral(ConstInt::Usize(u)) => u,
expr: &hir::Expr,
method_call: ty::MethodCall)
-> Expr<'tcx> {
- let tables = cx.tcx.tables.borrow();
- let callee = &tables.method_map[&method_call];
+ let callee = cx.tcx.tables().method_map[&method_call];
let temp_lifetime = cx.tcx.region_maps.temporary_scope(expr.id);
Expr {
temp_lifetime: temp_lifetime,
fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
expr: &'tcx hir::Expr)
-> ExprKind<'tcx> {
- let substs = cx.tcx.node_id_item_substs(expr.id).substs;
- // Otherwise there may be def_map borrow conflicts
+ let substs = cx.tcx.tables().node_id_item_substs(expr.id)
+ .unwrap_or_else(|| cx.tcx.intern_substs(&[]));
let def = cx.tcx.expect_def(expr.id);
let def_id = match def {
// A regular function, constructor function or a constant.
Def::Const(def_id) | Def::AssociatedConst(def_id) => def_id,
Def::StructCtor(def_id, CtorKind::Const) |
- Def::VariantCtor(def_id, CtorKind::Const) => match cx.tcx.node_id_to_type(expr.id).sty {
- // A unit struct/variant which is used as a value.
- // We return a completely different ExprKind here to account for this special case.
- ty::TyAdt(adt_def, substs) => return ExprKind::Adt {
- adt_def: adt_def,
- variant_index: adt_def.variant_index_with_id(def_id),
- substs: substs,
- fields: vec![],
- base: None,
- },
- ref sty => bug!("unexpected sty: {:?}", sty)
- },
+ Def::VariantCtor(def_id, CtorKind::Const) => {
+ match cx.tcx.tables().node_id_to_type(expr.id).sty {
+ // A unit struct/variant which is used as a value.
+ // We return a completely different ExprKind here to account for this special case.
+ ty::TyAdt(adt_def, substs) => return ExprKind::Adt {
+ adt_def: adt_def,
+ variant_index: adt_def.variant_index_with_id(def_id),
+ substs: substs,
+ fields: vec![],
+ base: None,
+ },
+ ref sty => bug!("unexpected sty: {:?}", sty)
+ }
+ }
Def::Static(node_id, _) => return ExprKind::StaticRef {
id: node_id,
Def::Upvar(def_id, index, closure_expr_id) => {
let id_var = cx.tcx.map.as_local_node_id(def_id).unwrap();
debug!("convert_var(upvar({:?}, {:?}, {:?}))", id_var, index, closure_expr_id);
- let var_ty = cx.tcx.node_id_to_type(id_var);
+ let var_ty = cx.tcx.tables().node_id_to_type(id_var);
let body_id = match cx.tcx.map.find(closure_expr_id) {
Some(map::NodeExpr(expr)) => {
};
// FIXME free regions in closures are not right
- let closure_ty = cx.tcx.node_id_to_type(closure_expr_id);
+ let closure_ty = cx.tcx.tables().node_id_to_type(closure_expr_id);
// FIXME we're just hard-coding the idea that the
// signature will be &self or &mut self and hence will
var_id: id_var,
closure_expr_id: closure_expr_id,
};
- let upvar_capture = match cx.tcx.upvar_capture(upvar_id) {
+ let upvar_capture = match cx.tcx.tables().upvar_capture(upvar_id) {
Some(c) => c,
None => {
span_bug!(
// line up (this is because `*x` and `x[y]` represent lvalues):
// to find the type &T of the content returned by the method;
- let tables = cx.tcx.tables.borrow();
- let callee = &tables.method_map[&method_call];
- let ref_ty = callee.ty.fn_ret();
+ let ref_ty = cx.tcx.tables().method_map[&method_call].ty.fn_ret();
let ref_ty = cx.tcx.no_late_bound_regions(&ref_ty).unwrap();
// callees always have all late-bound regions fully instantiated,
var_id: id_var,
closure_expr_id: closure_expr.id,
};
- let upvar_capture = cx.tcx.upvar_capture(upvar_id).unwrap();
+ let upvar_capture = cx.tcx.tables().upvar_capture(upvar_id).unwrap();
let temp_lifetime = cx.tcx.region_maps.temporary_scope(closure_expr.id);
- let var_ty = cx.tcx.node_id_to_type(id_var);
+ let var_ty = cx.tcx.tables().node_id_to_type(id_var);
let captured_var = Expr {
temp_lifetime: temp_lifetime,
ty: var_ty,
id: ast::NodeId) {
// fetch the fully liberated fn signature (that is, all bound
// types/lifetimes replaced)
- let fn_sig = match self.tcx.tables.borrow().liberated_fn_sigs.get(&id) {
+ let fn_sig = match self.tcx.tables().liberated_fn_sigs.get(&id) {
Some(f) => f.clone(),
None => {
span_bug!(span, "no liberated fn sig for {:?}", id);
closure_expr_id: ast::NodeId,
body_id: ast::NodeId)
-> Ty<'tcx> {
- let closure_ty = tcx.node_id_to_type(closure_expr_id);
+ let closure_ty = tcx.tables().node_id_to_type(closure_expr_id);
// We're just hard-coding the idea that the signature will be
// &self or &mut self and hence will have a bound region with
let mut outer = self.qualif;
self.qualif = ConstQualif::empty();
- let node_ty = self.tcx.node_id_to_type(ex.id);
+ let node_ty = self.tcx.tables().node_id_to_type(ex.id);
check_expr(self, ex, node_ty);
check_adjustments(self, ex);
match e.node {
hir::ExprUnary(..) |
hir::ExprBinary(..) |
- hir::ExprIndex(..) if v.tcx.tables.borrow().method_map.contains_key(&method_call) => {
+ hir::ExprIndex(..) if v.tcx.tables().method_map.contains_key(&method_call) => {
v.add_qualif(ConstQualif::NOT_CONST);
}
hir::ExprBox(_) => {
v.add_qualif(ConstQualif::NOT_CONST);
}
hir::ExprUnary(op, ref inner) => {
- match v.tcx.node_id_to_type(inner.id).sty {
+ match v.tcx.tables().node_id_to_type(inner.id).sty {
ty::TyRawPtr(_) => {
assert!(op == hir::UnDeref);
}
}
hir::ExprBinary(op, ref lhs, _) => {
- match v.tcx.node_id_to_type(lhs.id).sty {
+ match v.tcx.tables().node_id_to_type(lhs.id).sty {
ty::TyRawPtr(_) => {
assert!(op.node == hir::BiEq || op.node == hir::BiNe ||
op.node == hir::BiLe || op.node == hir::BiLt ||
}
}
Def::Const(did) | Def::AssociatedConst(did) => {
- let substs = Some(v.tcx.node_id_item_substs(e.id).substs);
+ let substs = Some(v.tcx.tables().node_id_item_substs(e.id)
+ .unwrap_or_else(|| v.tcx.intern_substs(&[])));
if let Some((expr, _)) = lookup_const_by_id(v.tcx, did, substs) {
let inner = v.global_expr(Mode::Const, expr);
v.add_qualif(inner);
}
}
hir::ExprMethodCall(..) => {
- let method = v.tcx.tables.borrow().method_map[&method_call];
+ let method = v.tcx.tables().method_map[&method_call];
let is_const = match v.tcx.impl_or_trait_item(method.def_id).container() {
ty::ImplContainer(_) => v.handle_const_fn_call(e, method.def_id, node_ty),
ty::TraitContainer(_) => false
}
}
hir::ExprStruct(..) => {
- if let ty::TyAdt(adt, ..) = v.tcx.expr_ty(e).sty {
+ if let ty::TyAdt(adt, ..) = v.tcx.tables().expr_ty(e).sty {
// unsafe_cell_type doesn't necessarily exist with no_core
if Some(adt.did) == v.tcx.lang_items.unsafe_cell_type() {
v.add_qualif(ConstQualif::MUTABLE_MEM);
/// Check the adjustments of an expression
fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr) {
- match v.tcx.tables.borrow().adjustments.get(&e.id) {
+ match v.tcx.tables().adjustments.get(&e.id) {
None |
Some(&ty::adjustment::AdjustNeverToAny(..)) |
Some(&ty::adjustment::AdjustReifyFnPointer) |
Some(&ty::adjustment::AdjustDerefRef(ty::adjustment::AutoDerefRef { autoderefs, .. })) => {
if (0..autoderefs as u32)
- .any(|autoderef| v.tcx.is_overloaded_autoderef(e.id, autoderef)) {
+ .any(|autoderef| v.tcx.tables().is_overloaded_autoderef(e.id, autoderef)) {
v.add_qualif(ConstQualif::NOT_CONST);
}
}
match expr.node {
hir::ExprMethodCall(..) => {
let method_call = ty::MethodCall::expr(expr.id);
- let method = self.tcx.tables.borrow().method_map[&method_call];
+ let method = self.tcx.tables().method_map[&method_call];
self.check_method(expr.span, method.def_id);
}
hir::ExprStruct(_, ref expr_fields, _) => {
- let adt = self.tcx.expr_ty(expr).ty_adt_def().unwrap();
+ let adt = self.tcx.tables().expr_ty(expr).ty_adt_def().unwrap();
let variant = adt.variant_of_def(self.tcx.expect_def(expr.id));
// RFC 736: ensure all unmentioned fields are visible.
// Rather than computing the set of unmentioned fields
match pattern.node {
PatKind::Struct(_, ref fields, _) => {
- let adt = self.tcx.pat_ty(pattern).ty_adt_def().unwrap();
+ let adt = self.tcx.tables().pat_ty(pattern).ty_adt_def().unwrap();
let variant = adt.variant_of_def(self.tcx.expect_def(pattern.id));
for field in fields {
self.check_field(field.span, adt, variant.field_named(field.node.name));
}
}
PatKind::TupleStruct(_, ref fields, ddpos) => {
- match self.tcx.pat_ty(pattern).sty {
+ match self.tcx.tables().pat_ty(pattern).sty {
// enum fields have no privacy at this time
ty::TyAdt(def, _) if !def.is_enum() => {
let expected_len = def.struct_variant().fields.len();
collector.visit_pat(&arg.pat);
let span_utils = self.span.clone();
for &(id, ref p, ..) in &collector.collected_paths {
- let typ = self.tcx.node_types().get(&id).unwrap().to_string();
+ let typ = self.tcx.tables().node_types.get(&id).unwrap().to_string();
// get the span only for the name of the variable (I hope the path is only ever a
// variable name, but who knows?)
let sub_span = span_utils.span_for_last_ident(p.span);
match p.node {
PatKind::Struct(ref path, ref fields, _) => {
visit::walk_path(self, path);
- let adt = self.tcx.node_id_to_type(p.id).ty_adt_def().unwrap();
+ let adt = self.tcx.tables().node_id_to_type(p.id).ty_adt_def().unwrap();
let variant = adt.variant_of_def(self.tcx.expect_def(p.id));
for &Spanned { node: ref field, span } in fields {
ast::Mutability::Immutable => value.to_string(),
_ => String::new(),
};
- let types = self.tcx.node_types();
- let typ = match types.get(&id) {
+ let typ = match self.tcx.tables().node_types.get(&id) {
Some(typ) => {
let typ = typ.to_string();
if !value.is_empty() {
}
ast::ExprKind::Struct(ref path, ref fields, ref base) => {
let hir_expr = self.save_ctxt.tcx.map.expect_expr(ex.id);
- let adt = self.tcx.expr_ty(&hir_expr).ty_adt_def().unwrap();
+ let adt = self.tcx.tables().expr_ty(&hir_expr).ty_adt_def().unwrap();
let def = self.tcx.expect_def(hir_expr.id);
self.process_struct_lit(ex, path, fields, adt.variant_of_def(def), base)
}
} else {
"<mutable>".to_string()
};
- let typ = self.tcx.node_types()
+ let typ = self.tcx.tables().node_types
.get(&id).map(|t| t.to_string()).unwrap_or(String::new());
value.push_str(": ");
value.push_str(&typ);
scope: NodeId) -> Option<VariableData> {
if let Some(ident) = field.ident {
let qualname = format!("::{}::{}", self.tcx.node_path_str(scope), ident);
- let typ = self.tcx.node_types().get(&field.id).unwrap().to_string();
+ let typ = self.tcx.tables().node_types.get(&field.id).unwrap().to_string();
let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon);
filter!(self.span_utils, sub_span, field.span, None);
Some(VariableData {
}
ast::ExprKind::MethodCall(..) => {
let method_call = ty::MethodCall::expr(expr.id);
- let method_id = self.tcx.tables.borrow().method_map[&method_call].def_id;
+ let method_id = self.tcx.tables().method_map[&method_call].def_id;
let (def_id, decl_id) = match self.tcx.impl_or_trait_item(method_id).container() {
ty::ImplContainer(_) => (Some(method_id), None),
ty::TraitContainer(_) => (None, Some(method_id)),
pub fn method_call<'blk>(bcx: Block<'blk, 'tcx>,
method_call: ty::MethodCall)
-> Callee<'tcx> {
- let method = bcx.tcx().tables.borrow().method_map[&method_call];
+ let method = bcx.tcx().tables().method_map[&method_call];
Callee::method(bcx, method)
}
hir::ItemStruct(_, ref generics) |
hir::ItemUnion(_, ref generics) => {
if !generics.is_parameterized() {
- let ty = {
- let tables = self.scx.tcx().tables.borrow();
- tables.node_types[&item.id]
- };
+ let ty = self.scx.tcx().tables().node_types[&item.id];
if self.mode == TransItemCollectionMode::Eager {
debug!("RootCollector: ADT drop-glue for {}",
};
let is_local_to_unit = is_node_local_to_unit(cx, node_id);
- let variable_type = tcx.erase_regions(&tcx.node_id_to_type(node_id));
+ let variable_type = tcx.erase_regions(&tcx.tables().node_id_to_type(node_id));
let type_metadata = type_metadata(cx, variable_type, span);
let var_name = tcx.item_name(node_def_id).to_string();
let linkage_name = mangled_name_of_item(cx, node_def_id, "");
tcx.prohibit_type_params(base_segments);
let impl_id = tcx.map.as_local_node_id(def_id).unwrap();
- let ty = tcx.node_id_to_type(impl_id);
+ let ty = tcx.tables().node_id_to_type(impl_id);
if let Some(free_substs) = self.get_free_substs() {
ty.subst(tcx, free_substs)
} else {
check_union(ccx, it.id, it.span);
}
hir::ItemTy(_, ref generics) => {
- let pty_ty = ccx.tcx.node_id_to_type(it.id);
+ let pty_ty = ccx.tcx.tables().node_id_to_type(it.id);
check_bounds_are_used(ccx, generics, pty_ty);
}
hir::ItemForeignMod(ref m) => {
sp: Span,
item_id: ast::NodeId)
-> bool {
- let rty = tcx.node_id_to_type(item_id);
+ let rty = tcx.tables().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
}
pub fn check_simd<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, id: ast::NodeId) {
- let t = tcx.node_id_to_type(id);
+ let t = tcx.tables().node_id_to_type(id);
match t.sty {
ty::TyAdt(def, substs) if def.is_struct() => {
let fields = &def.struct_variant().fields;
}
}
None => {
- let self_ty = fcx.tcx.node_id_to_type(item.id);
+ let self_ty = fcx.tcx.tables().node_id_to_type(item.id);
let self_ty = fcx.instantiate_type_scheme(item.span, free_substs, &self_ty);
fcx.register_wf_obligation(self_ty, ast_self_ty.span, this.code.clone());
}
item: &hir::Item,
ast_generics: &hir::Generics)
{
- let ty = self.tcx().node_id_to_type(item.id);
+ let ty = self.tcx().tables().node_id_to_type(item.id);
if self.tcx().has_error_field(ty) {
return;
}
let fields =
struct_def.fields().iter()
.map(|field| {
- let field_ty = self.tcx.node_id_to_type(field.id);
+ let field_ty = self.tcx.tables().node_id_to_type(field.id);
let field_ty = self.instantiate_type_scheme(field.span,
&self.parameter_environment
.free_substs,
debug!("Type for pattern binding {} (id {}) resolved to {:?}",
pat_to_string(p),
p.id,
- self.tcx().node_id_to_type(p.id));
+ self.tcx().tables().node_id_to_type(p.id));
intravisit::walk_pat(self, p);
}
main_id: ast::NodeId,
main_span: Span) {
let tcx = ccx.tcx;
- let main_t = tcx.node_id_to_type(main_id);
+ let main_t = tcx.tables().node_id_to_type(main_id);
match main_t.sty {
ty::TyFnDef(..) => {
match tcx.map.find(main_id) {
start_id: ast::NodeId,
start_span: Span) {
let tcx = ccx.tcx;
- let start_t = tcx.node_id_to_type(start_id);
+ let start_t = tcx.tables().node_id_to_type(start_id);
match start_t.sty {
ty::TyFnDef(..) => {
match tcx.map.find(start_id) {