@@ -203,15 +203,15 @@ impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelating<'cx, 'bccx, 'gcx, 'tcx> {
203
203
/// the region with; to do so, it indexes backwards into the list
204
204
/// of ambient scopes `scopes`.
205
205
fn lookup_bound_region (
206
- & self ,
207
206
debruijn : ty:: DebruijnIndex ,
208
207
br : & ty:: BoundRegion ,
208
+ first_free_index : ty:: DebruijnIndex ,
209
209
scopes : & [ BoundRegionScope ] ,
210
210
) -> RegionVid {
211
211
// The debruijn index is a "reverse index" into the
212
212
// scopes listing. So when we have INNERMOST (0), we
213
213
// 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 ( ) ;
215
215
let scope = & scopes[ scopes. len ( ) - debruijn_index - 1 ] ;
216
216
217
217
// 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> {
226
226
& self ,
227
227
universal_regions : & UniversalRegions < ' tcx > ,
228
228
r : ty:: Region < ' tcx > ,
229
+ first_free_index : ty:: DebruijnIndex ,
229
230
scopes : & [ BoundRegionScope ] ,
230
231
) -> RegionVid {
231
232
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
+ }
233
236
234
237
ty:: ReVar ( v) => * v,
235
238
@@ -380,8 +383,10 @@ impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx>
380
383
a, b, self . ambient_variance
381
384
) ;
382
385
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 ) ;
385
390
386
391
debug ! ( "regions: v_a = {:?}" , v_a) ;
387
392
debug ! ( "regions: v_b = {:?}" , v_b) ;
0 commit comments