Skip to content

Commit 39b9281

Browse files
committed
add a first_free_index parameter
1 parent 5c016f4 commit 39b9281

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,15 @@ impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelating<'cx, 'bccx, 'gcx, 'tcx> {
203203
/// the region with; to do so, it indexes backwards into the list
204204
/// of ambient scopes `scopes`.
205205
fn lookup_bound_region(
206-
&self,
207206
debruijn: ty::DebruijnIndex,
208207
br: &ty::BoundRegion,
208+
first_free_index: ty::DebruijnIndex,
209209
scopes: &[BoundRegionScope],
210210
) -> RegionVid {
211211
// The debruijn index is a "reverse index" into the
212212
// scopes listing. So when we have INNERMOST (0), we
213213
// want the *last* scope pushed, and so forth.
214-
let debruijn_index = debruijn.index() - ty::INNERMOST.index();
214+
let debruijn_index = debruijn.index() - first_free_index.index();
215215
let scope = &scopes[scopes.len() - debruijn_index - 1];
216216

217217
// Find this bound region in that scope to map to a
@@ -226,10 +226,13 @@ impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelating<'cx, 'bccx, 'gcx, 'tcx> {
226226
&self,
227227
universal_regions: &UniversalRegions<'tcx>,
228228
r: ty::Region<'tcx>,
229+
first_free_index: ty::DebruijnIndex,
229230
scopes: &[BoundRegionScope],
230231
) -> RegionVid {
231232
match r {
232-
ty::ReLateBound(debruijn, br) => self.lookup_bound_region(*debruijn, br, scopes),
233+
ty::ReLateBound(debruijn, br) => {
234+
Self::lookup_bound_region(*debruijn, br, first_free_index, scopes)
235+
}
233236

234237
ty::ReVar(v) => *v,
235238

@@ -380,8 +383,10 @@ impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx>
380383
a, b, self.ambient_variance
381384
);
382385

383-
let v_a = self.replace_bound_region(universal_regions, a, &self.a_scopes);
384-
let v_b = self.replace_bound_region(universal_regions, b, &self.b_scopes);
386+
let v_a =
387+
self.replace_bound_region(universal_regions, a, ty::INNERMOST, &self.a_scopes);
388+
let v_b =
389+
self.replace_bound_region(universal_regions, b, ty::INNERMOST, &self.b_scopes);
385390

386391
debug!("regions: v_a = {:?}", v_a);
387392
debug!("regions: v_b = {:?}", v_b);

0 commit comments

Comments
 (0)