]> git.lizzy.rs Git - rust.git/commitdiff
rustc: make all read access to tcx.tables go through a method.
authorEduard Burtescu <edy.burt@gmail.com>
Thu, 27 Oct 2016 01:52:10 +0000 (04:52 +0300)
committerEduard Burtescu <edy.burt@gmail.com>
Wed, 2 Nov 2016 01:50:32 +0000 (03:50 +0200)
35 files changed:
src/librustc/cfg/construct.rs
src/librustc/middle/dead.rs
src/librustc/middle/effect.rs
src/librustc/middle/intrinsicck.rs
src/librustc/middle/liveness.rs
src/librustc/middle/reachable.rs
src/librustc/middle/stability.rs
src/librustc/ty/context.rs
src/librustc/ty/mod.rs
src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs
src/librustc_const_eval/check_match.rs
src/librustc_const_eval/eval.rs
src/librustc_const_eval/pattern.rs
src/librustc_driver/pretty.rs
src/librustc_lint/builtin.rs
src/librustc_lint/types.rs
src/librustc_lint/unused.rs
src/librustc_metadata/astencode.rs
src/librustc_metadata/encoder.rs
src/librustc_mir/build/mod.rs
src/librustc_mir/hair/cx/block.rs
src/librustc_mir/hair/cx/expr.rs
src/librustc_mir/mir_map.rs
src/librustc_passes/consts.rs
src/librustc_privacy/lib.rs
src/librustc_save_analysis/dump_visitor.rs
src/librustc_save_analysis/lib.rs
src/librustc_trans/callee.rs
src/librustc_trans/collector.rs
src/librustc_trans/debuginfo/metadata.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/wfcheck.rs
src/librustc_typeck/check/writeback.rs
src/librustc_typeck/lib.rs

index 1b2976b7435d8e38ed66dc9cf9d9d2921aaa6324..8c7805b5450e3575044b7f5e41e676c68b170078 100644 (file)
@@ -311,11 +311,11 @@ fn expr(&mut self, expr: &hir::Expr, pred: CFGIndex) -> CFGIndex {
             }
 
             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())
             }
 
@@ -372,7 +372,7 @@ fn call<'b, I: Iterator<Item=&'b hir::Expr>>(&mut self,
             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)
         };
index dc634b08784a4a266031dab0a7befb94f716896b..daa32fc760faa6aa515a94594c2f06f630bb8b0a 100644 (file)
@@ -92,7 +92,7 @@ fn lookup_and_handle_definition(&mut self, id: ast::NodeId) {
         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);
                     }
@@ -123,7 +123,7 @@ fn lookup_and_handle_definition(&mut self, id: ast::NodeId) {
 
     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);
     }
 
@@ -148,7 +148,7 @@ fn handle_tup_field_access(&mut self, lhs: &hir::Expr, idx: usize) {
 
     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))
             }
@@ -433,7 +433,7 @@ fn should_warn_about_item(&mut self, item: &hir::Item) -> bool {
     }
 
     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
index 2a75b6620fd618ff40579a8e2a5237958f686df0..8964405fb7f778ac6e4d49ead9fb187f6ce02631 100644 (file)
@@ -159,7 +159,7 @@ fn visit_expr(&mut self, expr: &hir::Expr) {
         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) {
@@ -214,7 +214,7 @@ fn visit_expr(&mut self, expr: &hir::Expr) {
 
     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");
index 1acd0fb0f79c05d4c0c29fb3d0abd7e2e1f50dd1..57503398cfe577acd6aa87f5e37af21cb734e5c9 100644 (file)
@@ -163,7 +163,7 @@ fn visit_expr(&mut self, expr: &hir::Expr) {
         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];
index 79396b9ca4dab155cda150de99f7af64395c3a90..e544ddc402b5fdf42e1eb89bffdd9c1e673beab3 100644 (file)
@@ -1081,7 +1081,7 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
 
           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 {
@@ -1113,7 +1113,7 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
 
           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
@@ -1126,7 +1126,7 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
 
           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
@@ -1409,7 +1409,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
       }
 
       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);
         }
 
@@ -1459,7 +1459,7 @@ fn check_fn(_v: &Liveness,
 
 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(),
@@ -1502,7 +1502,7 @@ fn check_ret(&self,
                     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
                         },
index a476d0f6f30a673056748841055513c5a2189c31..1a50d7aa0adc7f34107bf6f5d05ee20541c4f624 100644 (file)
@@ -116,7 +116,7 @@ fn visit_expr(&mut self, expr: &hir::Expr) {
             }
             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
index 5192575972b0200ade1b38ac3a9cedf15b16530c..a03cf708e8c19d10071747b1cc68baeb20b4ee1d 100644 (file)
@@ -555,7 +555,7 @@ pub fn check_expr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, e: &hir::Expr,
         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;
@@ -580,7 +580,7 @@ pub fn check_expr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, e: &hir::Expr,
             }
         }
         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
@@ -637,7 +637,7 @@ pub fn check_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pat: &hir::Pat,
     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,
     };
index 62cc78141db468847f0cd70c59b390addb611e62..9a707a49b093f42000bd20f926a6e6759fba9bf4 100644 (file)
@@ -41,7 +41,7 @@
 
 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;
@@ -255,6 +255,65 @@ pub fn empty() -> Tables<'tcx> {
             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> {
@@ -599,14 +658,6 @@ pub fn type_parameter_def(self,
         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);
     }
index 588857e557c22fce71271141a104d135918afb1e..a378e22e5efd4a01fa9869cf1f682c1346a50cb1 100644 (file)
@@ -2120,52 +2120,8 @@ pub fn to_user_str(&self) -> &'static str {
 }
 
 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`
@@ -2178,21 +2134,21 @@ pub fn expr_ty_opt(self, expr: &hir::Expr) -> Option<Ty<'gcx>> {
     /// 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)
         }))
     }
 
@@ -2908,19 +2864,6 @@ pub fn node_scope_region(self, id: NodeId) -> &'tcx Region {
         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)
index 9bdc6887f6d03e74680a3a74fbb9a31d480f1926..51574868f9bfb5b72a2f8483f4356bef9539311b 100644 (file)
@@ -37,7 +37,7 @@ pub fn gather_decl<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
                              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);
 }
index 9aa1ac62f5523abf6b42d7ab4f143fc16ee6686c..615aca90db8bfd86497836f4c94938f8243407f9 100644 (file)
@@ -201,7 +201,7 @@ fn check_match(
 
             // 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
@@ -262,7 +262,7 @@ fn check_irrefutable(&self, pat: &Pat, is_fn_arg: bool) {
 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) {
@@ -486,7 +486,7 @@ fn check_legality_of_move_bindings(cx: &MatchVisitor,
     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));
                 }
index c02cca0da72255e5662fff0eda1086dfe1693517..1f66d7140682681173c01f4b90c2c9192f5e59ed 100644 (file)
@@ -246,7 +246,7 @@ pub fn const_expr_to_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                    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(_) => {
@@ -329,7 +329,8 @@ pub fn const_expr_to_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                 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);
                 },
@@ -606,7 +607,7 @@ pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     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
@@ -617,7 +618,7 @@ pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             // 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 {
@@ -759,7 +760,7 @@ pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         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
             }
@@ -798,7 +799,8 @@ pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
               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
                   };
index 946a3974747654d2ce00afd36532fe4d494b8e51..10b2a7625cacfefa1140ec965188e48d1cb7d516 100644 (file)
@@ -128,7 +128,7 @@ pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Self {
     }
 
     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,
@@ -167,8 +167,9 @@ pub fn lower_pattern(&mut self, pat: &hir::Pat) -> Pattern<'tcx> {
                 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)
@@ -197,7 +198,7 @@ pub fn lower_pattern(&mut self, pat: &hir::Pat) -> Pattern<'tcx> {
             }
 
             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 {
@@ -222,7 +223,7 @@ pub fn lower_pattern(&mut self, pat: &hir::Pat) -> Pattern<'tcx> {
             }
 
             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()
@@ -243,7 +244,7 @@ pub fn lower_pattern(&mut self, pat: &hir::Pat) -> Pattern<'tcx> {
             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,
@@ -280,7 +281,7 @@ pub fn lower_pattern(&mut self, pat: &hir::Pat) -> Pattern<'tcx> {
             }
 
             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"),
@@ -299,7 +300,7 @@ pub fn lower_pattern(&mut self, pat: &hir::Pat) -> Pattern<'tcx> {
             }
 
             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,
                     _ => {
index 10ff7dc89f9a33e5ddf38ac5ff728afb4e34fa23..8dee9b6ddd44d86830c3bfa98e19b223a13b34cd 100644 (file)
@@ -501,7 +501,7 @@ fn post(&self, s: &mut pprust_hir::State, node: pprust_hir::AnnNode) -> io::Resu
                 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(()),
index eee34324a6583a192dadd6b642640271642a1b66..6afcd18df0ad305e8587e3e9b511f954cee7daf8 100644 (file)
@@ -118,7 +118,9 @@ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
             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))
+            }
             _ => (),
         }
 
@@ -129,7 +131,7 @@ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
                 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));
                 }
             }
             _ => (),
@@ -137,7 +139,7 @@ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
     }
 
     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);
     }
 }
@@ -585,7 +587,7 @@ fn check_item(&mut self, cx: &LateContext, item: &hir::Item) {
             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);
                         }
@@ -940,7 +942,7 @@ fn expr_refers_to_this_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                                 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;
@@ -948,15 +950,12 @@ fn expr_refers_to_this_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             }
 
             // 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;
                         }
@@ -971,12 +970,10 @@ fn expr_refers_to_this_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                     // 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,
                     }
@@ -1213,7 +1210,7 @@ fn get_transmute_from_to<'a, 'tcx>
                 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];
@@ -1284,7 +1281,7 @@ fn check_item(&mut self, ctx: &LateContext, item: &hir::Item) {
         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,
index 9464bf30b693fd86dcedad02e5157c94a123fbb4..b04759955a956b8d3a43153d9b98b4b89a7da7a5 100644 (file)
@@ -113,14 +113,14 @@ fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
                             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);
                     }
@@ -138,7 +138,7 @@ fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
                 }
 
                 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,
@@ -171,7 +171,7 @@ fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
                 }
             }
             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(_)) |
@@ -324,7 +324,7 @@ fn check_limits<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             // 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 {
@@ -740,7 +740,7 @@ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
         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)
index a29ff18ab53188311c9ff13343fa7268c10222e0..2df09aa25c8becb19f4845aefe5ca818499fb72f 100644 (file)
@@ -140,7 +140,7 @@ fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) {
             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,
@@ -441,7 +441,7 @@ fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
             _ => 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 {
index f001f8513197894608907d2031976a41271173e3..63ec6a7069bb2955af5dcb2cb6b973aed3077fb5 100644 (file)
@@ -94,9 +94,9 @@ fn visit_id(&mut self, id: ast::NodeId) {
         };
 
         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));
     }
 }
index e8734e4275712411cb2894021fcec54a2be3cd79..fdb117ef81b13e731b638ad70e795466cdcdb0f6 100644 (file)
@@ -1016,7 +1016,7 @@ fn encode_info_for_closure(&mut self, def_id: DefId) -> Entry<'tcx> {
 
         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 {
index d6fcc79a9a2134bc9ad0b997f3ac16140ddb19ba..58526a3444e248139638d5b024e8a21e0084389a 100644 (file)
@@ -191,7 +191,7 @@ pub fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
     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()));
@@ -203,7 +203,7 @@ pub fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
     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 {
index ec1136368c1354317d18670e0b500be4f4dfa452..cb69de2cb3cace0923c907f0218e471cc3010649 100644 (file)
@@ -77,7 +77,7 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
 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,
index 1b324ac3132fcac6743fa1df9d3d578d12b5eb78..ddf487e9d7659197015937afa0d671b58e5ece8f 100644 (file)
@@ -37,10 +37,10 @@ fn make_mirror<'a, 'gcx>(self, cx: &mut Cx<'a, 'gcx, 'tcx>) -> Expr<'tcx> {
         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);
@@ -86,11 +86,11 @@ fn make_mirror<'a, 'gcx>(self, cx: &mut Cx<'a, 'gcx, 'tcx>) -> Expr<'tcx> {
                             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);
 
@@ -212,7 +212,7 @@ fn make_mirror<'a, 'gcx>(self, cx: &mut Cx<'a, 'gcx, 'tcx>) -> Expr<'tcx> {
 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 {
@@ -231,7 +231,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
         }
 
         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
@@ -282,7 +282,8 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
                     })
                 } 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()
@@ -296,7 +297,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
                     }
                 } 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(),
                     }
@@ -328,7 +329,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
         }
 
         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 {
@@ -350,7 +351,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
         },
 
         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 {
@@ -406,7 +407,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
         }
 
         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 {
@@ -418,7 +419,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
         }
 
         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 {
@@ -427,7 +428,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
         }
 
         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 {
@@ -439,7 +440,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
         }
 
         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 {
@@ -470,10 +471,8 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
                             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()
                                 }
                             })
                         }
@@ -512,7 +511,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
         }
 
         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),
                 _ => {
@@ -551,7 +550,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
         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,
@@ -631,8 +630,7 @@ fn method_callee<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
                                  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,
@@ -666,8 +664,8 @@ fn convert_arm<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
 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.
@@ -677,18 +675,20 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
         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,
@@ -720,7 +720,7 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
         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)) => {
@@ -737,7 +737,7 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
             };
 
             // 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
@@ -809,7 +809,7 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
                 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!(
@@ -931,9 +931,7 @@ fn overloaded_lvalue<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
     // 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,
 
@@ -962,9 +960,9 @@ fn capture_freevar<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
         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,
index b0e2d6e73d37aa0c3f19d7da16f893a2a4c47bef..0ffc59fe6bf45da6140208019e0e8419845ba63b 100644 (file)
@@ -214,7 +214,7 @@ fn visit_fn(&mut self,
                 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);
@@ -248,7 +248,7 @@ fn closure_self_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                              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
index 8ad4d7f57a6f0a4505c5116654acfc2b5de07fd3..20e9e76ab843ddc4c45bc86eb74d2910eeddf10c 100644 (file)
@@ -319,7 +319,7 @@ fn visit_expr(&mut self, ex: &hir::Expr) {
         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);
 
@@ -449,14 +449,14 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
     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);
 
@@ -466,7 +466,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
             }
         }
         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 ||
@@ -503,7 +503,8 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
                     }
                 }
                 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);
@@ -555,7 +556,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
             }
         }
         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
@@ -565,7 +566,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
             }
         }
         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);
@@ -624,7 +625,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
 
 /// 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) |
@@ -633,7 +634,7 @@ fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Exp
 
         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);
             }
         }
index 77b3e76fc541fd2da706a3c13f745bf41648da47..8fdfecd4a586519f3fac992ea2e9445adf324206 100644 (file)
@@ -430,11 +430,11 @@ fn visit_expr(&mut self, expr: &hir::Expr) {
         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
@@ -495,14 +495,14 @@ fn visit_pat(&mut self, pattern: &hir::Pat) {
 
         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();
index 8a628289b7f9421681df00473f559c9360938e32..3a092613a054afdd27fee80a557741b9d05ec45e 100644 (file)
@@ -356,7 +356,7 @@ fn process_formals(&mut self, formals: &Vec<ast::Arg>, qualname: &str) {
             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);
@@ -988,7 +988,7 @@ fn process_pat(&mut self, p: &ast::Pat) {
         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 {
@@ -1023,8 +1023,7 @@ fn process_var_decl(&mut self, p: &ast::Pat, value: String) {
                 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() {
@@ -1355,7 +1354,7 @@ fn visit_expr(&mut self, ex: &ast::Expr) {
             }
             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)
             }
@@ -1468,7 +1467,7 @@ fn visit_arm(&mut self, arm: &ast::Arm) {
                     } 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);
index 15c74f2ed6ab57411a7d5e49aebd4206d7123891..c111824a30cb563b63b73f0fa9ea92054caf93ce 100644 (file)
@@ -286,7 +286,7 @@ pub fn get_field_data(&self, field: &ast::StructField,
                           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 {
@@ -472,7 +472,7 @@ pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> {
             }
             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)),
index cd81d114eb7707c5fbc3ad282f4565e282a9135f..ffb13a833a582543e615fe7dba8e971f289e3590 100644 (file)
@@ -74,7 +74,7 @@ pub fn ptr(llfn: ValueRef, ty: Ty<'tcx>) -> Callee<'tcx> {
     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)
     }
 
index 8348da9f7b7bfe05cd49d19adcd9331e5620fb59..a439d415ede151f16e2f7e1418498e89b4f5a69f 100644 (file)
@@ -1082,10 +1082,7 @@ fn visit_item(&mut self, item: &'v hir::Item) {
             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 {}",
index 863aecc824433f4954f5847d340d4caad28b827b..4bb34850e0870c0cce998ceb9a57acb54ac81dbf 100644 (file)
@@ -1765,7 +1765,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 = 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, "");
index 8799050b1b999058b31213ca74f418abba88ba77..2db58ef066296cdfaea3b707f116e1da4c05a023 100644 (file)
@@ -1551,7 +1551,7 @@ fn base_def_to_ty(&self,
 
                 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 {
index 75a14bb3db9224ea5c367819a96362d8a6e966df..3fec347b75b933b0681988335454066fc89dd1dc 100644 (file)
@@ -773,7 +773,7 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
         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) => {
@@ -1188,7 +1188,7 @@ fn check_representable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                  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
@@ -1207,7 +1207,7 @@ fn check_representable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 }
 
 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;
index e3634cfe5f5e3212367992da1e7bc0991ddcdf1c..be1f2e35679d71e7ab191c5130a8fff33b87678a 100644 (file)
@@ -416,7 +416,7 @@ fn check_impl(&mut self,
                     }
                 }
                 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());
                 }
@@ -519,7 +519,7 @@ fn check_variances_for_type_defn(&self,
                                      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;
         }
@@ -649,7 +649,7 @@ fn struct_variant(&self, struct_def: &hir::VariantData) -> AdtVariant<'tcx> {
         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,
index 8685f703a599c8888f7becf687f9091f53d364e8..688bcbdcd121c60de24b64cde5b14f24db711843 100644 (file)
@@ -229,7 +229,7 @@ fn visit_pat(&mut self, p: &hir::Pat) {
         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);
     }
index c16dd788c4ec8d92a651e0f9c18bf1a9d8255a6f..5a48b5f0e1fd12bd1d1b376f9563847ea8f9c32b 100644 (file)
@@ -211,7 +211,7 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
                     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) {
@@ -263,7 +263,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
                      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) {