Skip to content

Commit 43a3348

Browse files
committed
Arena allocate the result of mir_borrowck
1 parent 378b5b4 commit 43a3348

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
@@ -419,13 +419,6 @@ rustc_queries! {
419419
query typeck_tables_of(key: DefId) -> &'tcx ty::TypeckTables<'tcx> {
420420
desc { |tcx| "type-checking `{}`", tcx.def_path_str(key) }
421421
cache_on_disk_if { key.is_local() }
422-
load_cached(tcx, id) {
423-
let typeck_tables: Option<ty::TypeckTables<'tcx>> = tcx
424-
.queries.on_disk_cache
425-
.try_load_query_result(tcx, id);
426-
427-
typeck_tables.map(|tables| &*tcx.arena.alloc(tables))
428-
}
429422
}
430423
query diagnostic_only_typeck_tables_of(key: DefId) -> &'tcx ty::TypeckTables<'tcx> {
431424
cache_on_disk_if { key.is_local() }
@@ -456,9 +449,13 @@ rustc_queries! {
456449
BorrowChecking {
457450
/// Borrow-checks the function body. If this is a closure, returns
458451
/// additional requirements that the closure's creator must verify.
459-
query mir_borrowck(key: DefId) -> mir::BorrowCheckResult<'tcx> {
452+
query mir_borrowck(key: DefId) -> &'tcx mir::BorrowCheckResult<'tcx> {
460453
desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key) }
461-
cache_on_disk_if(tcx, _) { key.is_local() && tcx.is_closure(key) }
454+
cache_on_disk_if(tcx, opt_result) {
455+
key.is_local()
456+
&& (tcx.is_closure(key)
457+
|| opt_result.map_or(false, |r| !r.concrete_opaque_types.is_empty()))
458+
}
462459
}
463460
}
464461

src/librustc_mir/borrow_check/mod.rs

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

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

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

104-
opt_closure_req
104+
tcx.arena.alloc(opt_closure_req)
105105
}
106106

107107
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
@@ -2512,7 +2512,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25122512
substs: SubstsRef<'tcx>,
25132513
location: Location,
25142514
) -> ty::InstantiatedPredicates<'tcx> {
2515-
if let Some(closure_region_requirements) = tcx.mir_borrowck(def_id).closure_requirements {
2515+
if let Some(ref closure_region_requirements) = tcx.mir_borrowck(def_id).closure_requirements
2516+
{
25162517
let closure_constraints = QueryRegionConstraints {
25172518
outlives: closure_region_requirements.apply_requirements(tcx, def_id, substs),
25182519

0 commit comments

Comments
 (0)