Accept LocalDefId
as key for mir_borrowck
query
This commit is contained in:
parent
82823c0229
commit
6e930f72d0
6 changed files with 21 additions and 18 deletions
|
@ -835,7 +835,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
|
|||
});
|
||||
|
||||
sess.time("MIR_borrow_checking", || {
|
||||
tcx.par_body_owners(|def_id| tcx.ensure().mir_borrowck(def_id.to_def_id()));
|
||||
tcx.par_body_owners(|def_id| tcx.ensure().mir_borrowck(def_id));
|
||||
});
|
||||
|
||||
sess.time("dumping_chalk_like_clauses", || {
|
||||
|
|
|
@ -494,12 +494,11 @@ 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) -> &'tcx mir::BorrowCheckResult<'tcx> {
|
||||
desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key) }
|
||||
query mir_borrowck(key: LocalDefId) -> &'tcx mir::BorrowCheckResult<'tcx> {
|
||||
desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key.to_def_id()) }
|
||||
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()))
|
||||
tcx.is_closure(key.to_def_id())
|
||||
|| opt_result.map_or(false, |r| !r.concrete_opaque_types.is_empty())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,14 +92,14 @@ pub fn provide(providers: &mut Providers<'_>) {
|
|||
*providers = Providers { mir_borrowck, ..*providers };
|
||||
}
|
||||
|
||||
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));
|
||||
fn mir_borrowck(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &BorrowCheckResult<'_> {
|
||||
let (input_body, promoted) = tcx.mir_validated(def_id.to_def_id());
|
||||
debug!("run query mir_borrowck: {}", tcx.def_path_str(def_id.to_def_id()));
|
||||
|
||||
let opt_closure_req = tcx.infer_ctxt().enter(|infcx| {
|
||||
let input_body: &Body<'_> = &input_body.borrow();
|
||||
let promoted: &IndexVec<_, _> = &promoted.borrow();
|
||||
do_mir_borrowck(&infcx, input_body, promoted, def_id.expect_local())
|
||||
do_mir_borrowck(&infcx, input_body, promoted, def_id)
|
||||
});
|
||||
debug!("mir_borrowck done");
|
||||
|
||||
|
@ -1268,7 +1268,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
match **aggregate_kind {
|
||||
AggregateKind::Closure(def_id, _) | AggregateKind::Generator(def_id, _, _) => {
|
||||
let BorrowCheckResult { used_mut_upvars, .. } =
|
||||
self.infcx.tcx.mir_borrowck(def_id);
|
||||
self.infcx.tcx.mir_borrowck(def_id.expect_local());
|
||||
debug!("{:?} used_mut_upvars={:?}", def_id, used_mut_upvars);
|
||||
for field in used_mut_upvars {
|
||||
self.propagate_closure_used_mut_upvar(&operands[field.index()]);
|
||||
|
|
|
@ -9,7 +9,7 @@ use rustc_data_structures::frozen::Frozen;
|
|||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_infer::infer::canonical::QueryRegionConstraints;
|
||||
use rustc_infer::infer::outlives::env::RegionBoundPairs;
|
||||
|
@ -2569,7 +2569,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
// clauses on the struct.
|
||||
AggregateKind::Closure(def_id, substs)
|
||||
| AggregateKind::Generator(def_id, substs, _) => {
|
||||
self.prove_closure_bounds(tcx, *def_id, substs, location)
|
||||
self.prove_closure_bounds(tcx, def_id.expect_local(), substs, location)
|
||||
}
|
||||
|
||||
AggregateKind::Array(_) | AggregateKind::Tuple => ty::InstantiatedPredicates::empty(),
|
||||
|
@ -2584,14 +2584,18 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
fn prove_closure_bounds(
|
||||
&mut self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
def_id: DefId,
|
||||
def_id: LocalDefId,
|
||||
substs: SubstsRef<'tcx>,
|
||||
location: Location,
|
||||
) -> ty::InstantiatedPredicates<'tcx> {
|
||||
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),
|
||||
outlives: closure_region_requirements.apply_requirements(
|
||||
tcx,
|
||||
def_id.to_def_id(),
|
||||
substs,
|
||||
),
|
||||
|
||||
// Presently, closures never propagate member
|
||||
// constraints to their parents -- they are enforced
|
||||
|
|
|
@ -371,7 +371,7 @@ fn optimized_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &Body<'_> {
|
|||
|
||||
// (Mir-)Borrowck uses `mir_validated`, so we have to force it to
|
||||
// execute before we can steal.
|
||||
tcx.ensure().mir_borrowck(def_id);
|
||||
tcx.ensure().mir_borrowck(def_id.expect_local());
|
||||
|
||||
let (body, _) = tcx.mir_validated(def_id);
|
||||
let mut body = body.steal();
|
||||
|
@ -387,7 +387,7 @@ fn promoted_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &IndexVec<Promoted, Body<'_>>
|
|||
return tcx.intern_promoted(IndexVec::new());
|
||||
}
|
||||
|
||||
tcx.ensure().mir_borrowck(def_id);
|
||||
tcx.ensure().mir_borrowck(def_id.expect_local());
|
||||
let (_, promoted) = tcx.mir_validated(def_id);
|
||||
let mut promoted = promoted.steal();
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
|
|||
ItemKind::OpaqueTy(OpaqueTy { impl_trait_fn: Some(owner), origin, .. }) => {
|
||||
let concrete_types = match origin {
|
||||
OpaqueTyOrigin::FnReturn | OpaqueTyOrigin::AsyncFn => {
|
||||
&tcx.mir_borrowck(owner).concrete_opaque_types
|
||||
&tcx.mir_borrowck(owner.expect_local()).concrete_opaque_types
|
||||
}
|
||||
OpaqueTyOrigin::Misc => {
|
||||
// We shouldn't leak borrowck results through impl trait in bindings.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue