Skip to content

Commit

Permalink
move PlaceholderIndices into MirTypeckRegionConstraints struct
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Oct 27, 2018
1 parent 42c11de commit 018c515
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/librustc_mir/borrow_check/nll/mod.rs
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand Down
8 changes: 3 additions & 5 deletions src/librustc_mir/borrow_check/nll/type_check/mod.rs
Expand Up @@ -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,
Expand All @@ -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(
Expand All @@ -175,7 +174,6 @@ pub(crate) fn type_check<'gcx, 'tcx>(

MirTypeckResults {
constraints,
placeholder_indices,
universal_region_relations,
}
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs
Expand Up @@ -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)
}
Expand Down

0 comments on commit 018c515

Please sign in to comment.