about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2019-12-26 17:26:53 +0000
committerMatthew Jasper <mjjasper1@gmail.com>2020-02-14 22:40:02 +0000
commit43a3348fd94568b78db7755bb5196fc73fa65214 (patch)
treeb42be70d3aa49d2f040d7f6fbef3410faa77c0a2
parent378b5b4ca06d027d9dfff807fe0fff4bc5e62806 (diff)
downloadrust-43a3348fd94568b78db7755bb5196fc73fa65214.tar.gz
rust-43a3348fd94568b78db7755bb5196fc73fa65214.zip
Arena allocate the result of mir_borrowck
-rw-r--r--src/librustc/arena.rs3
-rw-r--r--src/librustc/query/mod.rs15
-rw-r--r--src/librustc_mir/borrow_check/mod.rs4
-rw-r--r--src/librustc_mir/borrow_check/type_check/mod.rs3
4 files changed, 12 insertions, 13 deletions
diff --git a/src/librustc/arena.rs b/src/librustc/arena.rs
index dd242686d26..33cbf6ede0a 100644
--- a/src/librustc/arena.rs
+++ b/src/librustc/arena.rs
@@ -35,7 +35,8 @@ macro_rules! arena_types {
                 rustc::mir::Promoted,
                 rustc::mir::BodyAndCache<$tcx>
             >,
-            [] tables: rustc::ty::TypeckTables<$tcx>,
+            [decode] tables: rustc::ty::TypeckTables<$tcx>,
+            [decode] borrowck_result: rustc::mir::BorrowCheckResult<$tcx>,
             [] const_allocs: rustc::mir::interpret::Allocation,
             [] vtable_method: Option<(
                 rustc_hir::def_id::DefId,
diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs
index 1cc7c7a1c69..5e279975d15 100644
--- a/src/librustc/query/mod.rs
+++ b/src/librustc/query/mod.rs
@@ -419,13 +419,6 @@ rustc_queries! {
         query typeck_tables_of(key: DefId) -> &'tcx ty::TypeckTables<'tcx> {
             desc { |tcx| "type-checking `{}`", tcx.def_path_str(key) }
             cache_on_disk_if { key.is_local() }
-            load_cached(tcx, id) {
-                let typeck_tables: Option<ty::TypeckTables<'tcx>> = tcx
-                    .queries.on_disk_cache
-                    .try_load_query_result(tcx, id);
-
-                typeck_tables.map(|tables| &*tcx.arena.alloc(tables))
-            }
         }
         query diagnostic_only_typeck_tables_of(key: DefId) -> &'tcx ty::TypeckTables<'tcx> {
             cache_on_disk_if { key.is_local() }
@@ -456,9 +449,13 @@ rustc_queries! {
     BorrowChecking {
         /// Borrow-checks the function body. If this is a closure, returns
         /// additional requirements that the closure's creator must verify.
-        query mir_borrowck(key: DefId) -> mir::BorrowCheckResult<'tcx> {
+        query mir_borrowck(key: DefId) -> &'tcx mir::BorrowCheckResult<'tcx> {
             desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key) }
-            cache_on_disk_if(tcx, _) { key.is_local() && tcx.is_closure(key) }
+            cache_on_disk_if(tcx, opt_result) {
+                key.is_local()
+                    && (tcx.is_closure(key)
+                        || opt_result.map_or(false, |r| !r.concrete_opaque_types.is_empty()))
+            }
         }
     }
 
diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs
index 941534e68fc..07d3a12fb20 100644
--- a/src/librustc_mir/borrow_check/mod.rs
+++ b/src/librustc_mir/borrow_check/mod.rs
@@ -90,7 +90,7 @@ pub fn provide(providers: &mut Providers<'_>) {
     *providers = Providers { mir_borrowck, ..*providers };
 }
 
-fn mir_borrowck(tcx: TyCtxt<'_>, def_id: DefId) -> BorrowCheckResult<'_> {
+fn mir_borrowck(tcx: TyCtxt<'_>, def_id: DefId) -> &BorrowCheckResult<'_> {
     let (input_body, promoted) = tcx.mir_validated(def_id);
     debug!("run query mir_borrowck: {}", tcx.def_path_str(def_id));
 
@@ -101,7 +101,7 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def_id: DefId) -> BorrowCheckResult<'_> {
     });
     debug!("mir_borrowck done");
 
-    opt_closure_req
+    tcx.arena.alloc(opt_closure_req)
 }
 
 fn do_mir_borrowck<'a, 'tcx>(
diff --git a/src/librustc_mir/borrow_check/type_check/mod.rs b/src/librustc_mir/borrow_check/type_check/mod.rs
index 5dab064c7b7..67dbf8a2b6d 100644
--- a/src/librustc_mir/borrow_check/type_check/mod.rs
+++ b/src/librustc_mir/borrow_check/type_check/mod.rs
@@ -2512,7 +2512,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
         substs: SubstsRef<'tcx>,
         location: Location,
     ) -> ty::InstantiatedPredicates<'tcx> {
-        if let Some(closure_region_requirements) = tcx.mir_borrowck(def_id).closure_requirements {
+        if let Some(ref closure_region_requirements) = tcx.mir_borrowck(def_id).closure_requirements
+        {
             let closure_constraints = QueryRegionConstraints {
                 outlives: closure_region_requirements.apply_requirements(tcx, def_id, substs),