move PlaceholderIndices into MirTypeckRegionConstraints struct

This commit is contained in:
Niko Matsakis 2018-09-28 16:55:15 -04:00
parent 42c11de47b
commit 018c515f07
3 changed files with 6 additions and 9 deletions

View file

@ -107,7 +107,6 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
// Run the MIR type-checker.
let MirTypeckResults {
constraints,
placeholder_indices,
universal_region_relations,
} = type_check::type_check(
infcx,
@ -123,8 +122,6 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
elements,
);
let placeholder_indices = Rc::new(placeholder_indices);
if let Some(all_facts) = &mut all_facts {
all_facts
.universal_region
@ -136,11 +133,13 @@ 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 {
placeholder_indices,
mut liveness_constraints,
outlives_constraints,
closure_bounds_mapping,
type_tests,
} = constraints;
let placeholder_indices = Rc::new(placeholder_indices);
constraint_generation::generate_constraints(
infcx,

View file

@ -126,12 +126,12 @@ pub(crate) fn type_check<'gcx, 'tcx>(
) -> MirTypeckResults<'tcx> {
let implicit_region_bound = infcx.tcx.mk_region(ty::ReVar(universal_regions.fr_fn_body));
let mut constraints = MirTypeckRegionConstraints {
placeholder_indices: PlaceholderIndices::default(),
liveness_constraints: LivenessValues::new(elements),
outlives_constraints: ConstraintSet::default(),
closure_bounds_mapping: Default::default(),
type_tests: Vec::default(),
};
let mut placeholder_indices = PlaceholderIndices::default();
let CreateResult {
universal_region_relations,
@ -151,7 +151,6 @@ pub(crate) fn type_check<'gcx, 'tcx>(
borrow_set,
all_facts,
constraints: &mut constraints,
placeholder_indices: &mut placeholder_indices,
};
type_check_internal(
@ -175,7 +174,6 @@ pub(crate) fn type_check<'gcx, 'tcx>(
MirTypeckResults {
constraints,
placeholder_indices,
universal_region_relations,
}
}
@ -730,18 +728,18 @@ struct BorrowCheckContext<'a, 'tcx: 'a> {
all_facts: &'a mut Option<AllFacts>,
borrow_set: &'a BorrowSet<'tcx>,
constraints: &'a mut MirTypeckRegionConstraints<'tcx>,
placeholder_indices: &'a mut PlaceholderIndices,
}
crate struct MirTypeckResults<'tcx> {
crate constraints: MirTypeckRegionConstraints<'tcx>,
crate placeholder_indices: PlaceholderIndices,
crate universal_region_relations: Rc<UniversalRegionRelations<'tcx>>,
}
/// A collection of region constraints that must be satisfied for the
/// program to be considered well-typed.
crate struct MirTypeckRegionConstraints<'tcx> {
crate placeholder_indices: PlaceholderIndices,
/// In general, the type-checker is not responsible for enforcing
/// liveness constraints; this job falls to the region inferencer,
/// which performs a liveness analysis. However, in some limited

View file

@ -83,7 +83,7 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, '_, 'tcx> {
fn next_placeholder_region(&mut self, placeholder: ty::Placeholder) -> ty::Region<'tcx> {
let origin = NLLRegionVariableOrigin::Placeholder(placeholder);
if let Some(borrowck_context) = &mut self.borrowck_context {
borrowck_context.placeholder_indices.insert(placeholder);
borrowck_context.constraints.placeholder_indices.insert(placeholder);
}
self.infcx.next_nll_region_var(origin)
}