generate extra liveness constraints before regioncx is created
This commit is contained in:
parent
92786a48f8
commit
f277b394af
2 changed files with 21 additions and 15 deletions
|
@ -12,7 +12,7 @@ use borrow_check::borrow_set::BorrowSet;
|
|||
use borrow_check::location::LocationTable;
|
||||
use borrow_check::nll::ToRegionVid;
|
||||
use borrow_check::nll::facts::AllFacts;
|
||||
use borrow_check::nll::region_infer::RegionInferenceContext;
|
||||
use borrow_check::nll::region_infer::values::{RegionValueElements, RegionValues};
|
||||
use rustc::infer::InferCtxt;
|
||||
use rustc::mir::visit::TyContext;
|
||||
use rustc::mir::visit::Visitor;
|
||||
|
@ -20,11 +20,12 @@ use rustc::mir::{BasicBlock, BasicBlockData, Location, Mir, Place, Rvalue};
|
|||
use rustc::mir::{Local, Statement, Terminator};
|
||||
use rustc::ty::fold::TypeFoldable;
|
||||
use rustc::ty::subst::Substs;
|
||||
use rustc::ty::{self, CanonicalTy, ClosureSubsts, GeneratorSubsts};
|
||||
use rustc::ty::{self, CanonicalTy, ClosureSubsts, GeneratorSubsts, RegionVid};
|
||||
|
||||
pub(super) fn generate_constraints<'cx, 'gcx, 'tcx>(
|
||||
infcx: &InferCtxt<'cx, 'gcx, 'tcx>,
|
||||
regioncx: &mut RegionInferenceContext<'tcx>,
|
||||
elements: &RegionValueElements,
|
||||
liveness_constraints: &mut RegionValues<RegionVid>,
|
||||
all_facts: &mut Option<AllFacts>,
|
||||
location_table: &LocationTable,
|
||||
mir: &Mir<'tcx>,
|
||||
|
@ -33,9 +34,10 @@ pub(super) fn generate_constraints<'cx, 'gcx, 'tcx>(
|
|||
let mut cg = ConstraintGeneration {
|
||||
borrow_set,
|
||||
infcx,
|
||||
regioncx,
|
||||
liveness_constraints,
|
||||
location_table,
|
||||
all_facts,
|
||||
elements,
|
||||
};
|
||||
|
||||
for (bb, data) in mir.basic_blocks().iter_enumerated() {
|
||||
|
@ -48,8 +50,9 @@ struct ConstraintGeneration<'cg, 'cx: 'cg, 'gcx: 'tcx, 'tcx: 'cx> {
|
|||
infcx: &'cg InferCtxt<'cx, 'gcx, 'tcx>,
|
||||
all_facts: &'cg mut Option<AllFacts>,
|
||||
location_table: &'cg LocationTable,
|
||||
regioncx: &'cg mut RegionInferenceContext<'tcx>,
|
||||
liveness_constraints: &'cg mut RegionValues<RegionVid>,
|
||||
borrow_set: &'cg BorrowSet<'tcx>,
|
||||
elements: &'cg RegionValueElements,
|
||||
}
|
||||
|
||||
impl<'cg, 'cx, 'gcx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'gcx, 'tcx> {
|
||||
|
@ -202,7 +205,7 @@ impl<'cx, 'cg, 'gcx, 'tcx> ConstraintGeneration<'cx, 'cg, 'gcx, 'tcx> {
|
|||
.tcx
|
||||
.for_each_free_region(&live_ty, |live_region| {
|
||||
let vid = live_region.to_region_vid();
|
||||
self.regioncx.add_live_element(vid, location);
|
||||
self.liveness_constraints.add_element(&self.elements, vid, location);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,10 +136,21 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
|
|||
// base constraints generated by the type-check.
|
||||
let var_origins = infcx.take_region_var_origins();
|
||||
let MirTypeckRegionConstraints {
|
||||
liveness_constraints,
|
||||
mut liveness_constraints,
|
||||
outlives_constraints,
|
||||
type_tests,
|
||||
} = constraint_sets;
|
||||
|
||||
constraint_generation::generate_constraints(
|
||||
infcx,
|
||||
&elements,
|
||||
&mut liveness_constraints,
|
||||
&mut all_facts,
|
||||
location_table,
|
||||
&mir,
|
||||
borrow_set,
|
||||
);
|
||||
|
||||
let mut regioncx = RegionInferenceContext::new(
|
||||
var_origins,
|
||||
universal_regions,
|
||||
|
@ -151,14 +162,6 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
|
|||
);
|
||||
|
||||
// Generate various additional constraints.
|
||||
constraint_generation::generate_constraints(
|
||||
infcx,
|
||||
&mut regioncx,
|
||||
&mut all_facts,
|
||||
location_table,
|
||||
&mir,
|
||||
borrow_set,
|
||||
);
|
||||
invalidation::generate_invalidates(
|
||||
infcx,
|
||||
&mut all_facts,
|
||||
|
|
Loading…
Reference in a new issue