Skip to content

Commit f158ca9

Browse files
committed
Arena allocate the result of mir_borrowck
1 parent c1786da commit f158ca9

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

src/librustc/arena.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ macro_rules! arena_types {
3535
rustc::mir::Promoted,
3636
rustc::mir::BodyAndCache<$tcx>
3737
>,
38-
[] tables: rustc::ty::TypeckTables<$tcx>,
38+
[decode] tables: rustc::ty::TypeckTables<$tcx>,
39+
[decode] borrowck_result: rustc::mir::BorrowCheckResult<$tcx>,
3940
[] const_allocs: rustc::mir::interpret::Allocation,
4041
[] vtable_method: Option<(
4142
rustc_hir::def_id::DefId,

src/librustc/query/mod.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,6 @@ rustc_queries! {
402402
query typeck_tables_of(key: DefId) -> &'tcx ty::TypeckTables<'tcx> {
403403
desc { |tcx| "type-checking `{}`", tcx.def_path_str(key) }
404404
cache_on_disk_if { key.is_local() }
405-
load_cached(tcx, id) {
406-
let typeck_tables: Option<ty::TypeckTables<'tcx>> = tcx
407-
.queries.on_disk_cache
408-
.try_load_query_result(tcx, id);
409-
410-
typeck_tables.map(|tables| &*tcx.arena.alloc(tables))
411-
}
412405
}
413406
query diagnostic_only_typeck_tables_of(key: DefId) -> &'tcx ty::TypeckTables<'tcx> {
414407
cache_on_disk_if { key.is_local() }
@@ -439,9 +432,13 @@ rustc_queries! {
439432
BorrowChecking {
440433
/// Borrow-checks the function body. If this is a closure, returns
441434
/// additional requirements that the closure's creator must verify.
442-
query mir_borrowck(key: DefId) -> mir::BorrowCheckResult<'tcx> {
435+
query mir_borrowck(key: DefId) -> &'tcx mir::BorrowCheckResult<'tcx> {
443436
desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key) }
444-
cache_on_disk_if(tcx, _) { key.is_local() && tcx.is_closure(key) }
437+
cache_on_disk_if(tcx, opt_result) {
438+
key.is_local()
439+
&& (tcx.is_closure(key)
440+
|| opt_result.map_or(false, |r| !r.concrete_opaque_types.is_empty()))
441+
}
445442
}
446443
}
447444

src/librustc_mir/borrow_check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn provide(providers: &mut Providers<'_>) {
9292
*providers = Providers { mir_borrowck, ..*providers };
9393
}
9494

95-
fn mir_borrowck(tcx: TyCtxt<'_>, def_id: DefId) -> BorrowCheckResult<'_> {
95+
fn mir_borrowck(tcx: TyCtxt<'_>, def_id: DefId) -> &BorrowCheckResult<'_> {
9696
let (input_body, promoted) = tcx.mir_validated(def_id);
9797
debug!("run query mir_borrowck: {}", tcx.def_path_str(def_id));
9898

@@ -103,7 +103,7 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def_id: DefId) -> BorrowCheckResult<'_> {
103103
});
104104
debug!("mir_borrowck done");
105105

106-
opt_closure_req
106+
tcx.arena.alloc(opt_closure_req)
107107
}
108108

109109
fn do_mir_borrowck<'a, 'tcx>(

src/librustc_mir/borrow_check/type_check/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2510,7 +2510,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25102510
substs: SubstsRef<'tcx>,
25112511
location: Location,
25122512
) -> ty::InstantiatedPredicates<'tcx> {
2513-
if let Some(closure_region_requirements) = tcx.mir_borrowck(def_id).closure_requirements {
2513+
if let Some(ref closure_region_requirements) = tcx.mir_borrowck(def_id).closure_requirements
2514+
{
25142515
let closure_constraints = QueryRegionConstraints {
25152516
outlives: closure_region_requirements.apply_requirements(tcx, def_id, substs),
25162517

0 commit comments

Comments
 (0)