]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/hair/cx/mod.rs
rustc: do not depend on infcx.tables in MemCategorizationContext.
[rust.git] / src / librustc_mir / hair / cx / mod.rs
index 5b7b52a72b0ab4c625c19b24d863def31b7c2b73..2bb6b39966a82021fda4658c87ef462863f80167 100644 (file)
@@ -37,6 +37,7 @@ pub struct Cx<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
     infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
     pub param_env: ty::ParamEnv<'tcx>,
     pub region_maps: Rc<RegionMaps>,
+    pub tables: &'a ty::TypeckTables<'gcx>,
 
     /// This is `Constness::Const` if we are compiling a `static`,
     /// `const`, or the body of a `const fn`.
@@ -67,6 +68,7 @@ pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, src: MirSource) -> Cx<'a, 'gcx,
 
         let param_env = tcx.param_env(src_def_id);
         let region_maps = tcx.region_maps(src_def_id);
+        let tables = tcx.typeck_tables_of(src_def_id);
 
         let attrs = tcx.hir.attrs(src_id);
 
@@ -82,7 +84,7 @@ pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, src: MirSource) -> Cx<'a, 'gcx,
         // Constants and const fn's always need overflow checks.
         check_overflow |= constness == hir::Constness::Const;
 
-        Cx { tcx, infcx, param_env, region_maps, constness, src, check_overflow }
+        Cx { tcx, infcx, param_env, region_maps, tables, constness, src, check_overflow }
     }
 }
 
@@ -184,7 +186,7 @@ pub fn tcx(&self) -> TyCtxt<'a, 'gcx, 'tcx> {
     }
 
     pub fn tables(&self) -> &'a ty::TypeckTables<'gcx> {
-        self.infcx.tables.expect_interned()
+        self.tables
     }
 
     pub fn check_overflow(&self) -> bool {