about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2018-08-31 15:41:27 -0400
committerNiko Matsakis <niko@alum.mit.edu>2018-09-09 14:14:41 -0400
commit39b9281562b7103be23e4546de9a4e5a886d2747 (patch)
tree94128a14e8a8d537de223fa3b6442099a129eb8f
parent5c016f4cb51e79a6ec3cae25f5d6c11ed92fe6da (diff)
downloadrust-39b9281562b7103be23e4546de9a4e5a886d2747.tar.gz
rust-39b9281562b7103be23e4546de9a4e5a886d2747.zip
add a `first_free_index` parameter
-rw-r--r--src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs
index 0e945ad3341..217ec45320e 100644
--- a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs
+++ b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs
@@ -203,15 +203,15 @@ impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelating<'cx, 'bccx, 'gcx, 'tcx> {
     /// the region with; to do so, it indexes backwards into the list
     /// of ambient scopes `scopes`.
     fn lookup_bound_region(
-        &self,
         debruijn: ty::DebruijnIndex,
         br: &ty::BoundRegion,
+        first_free_index: ty::DebruijnIndex,
         scopes: &[BoundRegionScope],
     ) -> RegionVid {
         // The debruijn index is a "reverse index" into the
         // scopes listing. So when we have INNERMOST (0), we
         // want the *last* scope pushed, and so forth.
-        let debruijn_index = debruijn.index() - ty::INNERMOST.index();
+        let debruijn_index = debruijn.index() - first_free_index.index();
         let scope = &scopes[scopes.len() - debruijn_index - 1];
 
         // 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> {
         &self,
         universal_regions: &UniversalRegions<'tcx>,
         r: ty::Region<'tcx>,
+        first_free_index: ty::DebruijnIndex,
         scopes: &[BoundRegionScope],
     ) -> RegionVid {
         match r {
-            ty::ReLateBound(debruijn, br) => self.lookup_bound_region(*debruijn, br, scopes),
+            ty::ReLateBound(debruijn, br) => {
+                Self::lookup_bound_region(*debruijn, br, first_free_index, scopes)
+            }
 
             ty::ReVar(v) => *v,
 
@@ -380,8 +383,10 @@ impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx>
                 a, b, self.ambient_variance
             );
 
-            let v_a = self.replace_bound_region(universal_regions, a, &self.a_scopes);
-            let v_b = self.replace_bound_region(universal_regions, b, &self.b_scopes);
+            let v_a =
+                self.replace_bound_region(universal_regions, a, ty::INNERMOST, &self.a_scopes);
+            let v_b =
+                self.replace_bound_region(universal_regions, b, ty::INNERMOST, &self.b_scopes);
 
             debug!("regions: v_a = {:?}", v_a);
             debug!("regions: v_b = {:?}", v_b);