Skip to content

Commit

Permalink
Arena allocate the result of mir_borrowck
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewjasper committed Feb 14, 2020
1 parent 378b5b4 commit 43a3348
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/librustc/arena.rs
Expand Up @@ -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,
Expand Down
15 changes: 6 additions & 9 deletions src/librustc/query/mod.rs
Expand Up @@ -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() }
Expand Down Expand Up @@ -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()))
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/borrow_check/mod.rs
Expand Up @@ -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));

Expand All @@ -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>(
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_mir/borrow_check/type_check/mod.rs
Expand Up @@ -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),

Expand Down

0 comments on commit 43a3348

Please sign in to comment.