Skip to content

Commit 018c515

Browse files
committed
move PlaceholderIndices into MirTypeckRegionConstraints struct
1 parent 42c11de commit 018c515

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

src/librustc_mir/borrow_check/nll/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
107107
// Run the MIR type-checker.
108108
let MirTypeckResults {
109109
constraints,
110-
placeholder_indices,
111110
universal_region_relations,
112111
} = type_check::type_check(
113112
infcx,
@@ -123,8 +122,6 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
123122
elements,
124123
);
125124

126-
let placeholder_indices = Rc::new(placeholder_indices);
127-
128125
if let Some(all_facts) = &mut all_facts {
129126
all_facts
130127
.universal_region
@@ -136,11 +133,13 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
136133
// base constraints generated by the type-check.
137134
let var_origins = infcx.take_region_var_origins();
138135
let MirTypeckRegionConstraints {
136+
placeholder_indices,
139137
mut liveness_constraints,
140138
outlives_constraints,
141139
closure_bounds_mapping,
142140
type_tests,
143141
} = constraints;
142+
let placeholder_indices = Rc::new(placeholder_indices);
144143

145144
constraint_generation::generate_constraints(
146145
infcx,

src/librustc_mir/borrow_check/nll/type_check/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ pub(crate) fn type_check<'gcx, 'tcx>(
126126
) -> MirTypeckResults<'tcx> {
127127
let implicit_region_bound = infcx.tcx.mk_region(ty::ReVar(universal_regions.fr_fn_body));
128128
let mut constraints = MirTypeckRegionConstraints {
129+
placeholder_indices: PlaceholderIndices::default(),
129130
liveness_constraints: LivenessValues::new(elements),
130131
outlives_constraints: ConstraintSet::default(),
131132
closure_bounds_mapping: Default::default(),
132133
type_tests: Vec::default(),
133134
};
134-
let mut placeholder_indices = PlaceholderIndices::default();
135135

136136
let CreateResult {
137137
universal_region_relations,
@@ -151,7 +151,6 @@ pub(crate) fn type_check<'gcx, 'tcx>(
151151
borrow_set,
152152
all_facts,
153153
constraints: &mut constraints,
154-
placeholder_indices: &mut placeholder_indices,
155154
};
156155

157156
type_check_internal(
@@ -175,7 +174,6 @@ pub(crate) fn type_check<'gcx, 'tcx>(
175174

176175
MirTypeckResults {
177176
constraints,
178-
placeholder_indices,
179177
universal_region_relations,
180178
}
181179
}
@@ -730,18 +728,18 @@ struct BorrowCheckContext<'a, 'tcx: 'a> {
730728
all_facts: &'a mut Option<AllFacts>,
731729
borrow_set: &'a BorrowSet<'tcx>,
732730
constraints: &'a mut MirTypeckRegionConstraints<'tcx>,
733-
placeholder_indices: &'a mut PlaceholderIndices,
734731
}
735732

736733
crate struct MirTypeckResults<'tcx> {
737734
crate constraints: MirTypeckRegionConstraints<'tcx>,
738-
crate placeholder_indices: PlaceholderIndices,
739735
crate universal_region_relations: Rc<UniversalRegionRelations<'tcx>>,
740736
}
741737

742738
/// A collection of region constraints that must be satisfied for the
743739
/// program to be considered well-typed.
744740
crate struct MirTypeckRegionConstraints<'tcx> {
741+
crate placeholder_indices: PlaceholderIndices,
742+
745743
/// In general, the type-checker is not responsible for enforcing
746744
/// liveness constraints; this job falls to the region inferencer,
747745
/// which performs a liveness analysis. However, in some limited

src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, '_, 'tcx> {
8383
fn next_placeholder_region(&mut self, placeholder: ty::Placeholder) -> ty::Region<'tcx> {
8484
let origin = NLLRegionVariableOrigin::Placeholder(placeholder);
8585
if let Some(borrowck_context) = &mut self.borrowck_context {
86-
borrowck_context.placeholder_indices.insert(placeholder);
86+
borrowck_context.constraints.placeholder_indices.insert(placeholder);
8787
}
8888
self.infcx.next_nll_region_var(origin)
8989
}

0 commit comments

Comments
 (0)