@@ -239,6 +239,7 @@ where
239
239
first_free_index : ty:: DebruijnIndex ,
240
240
scopes : & [ BoundRegionScope < ' tcx > ] ,
241
241
) -> ty:: Region < ' tcx > {
242
+ debug ! ( "replace_bound_regions(scopes={:?})" , scopes) ;
242
243
if let ty:: ReLateBound ( debruijn, br) = r {
243
244
Self :: lookup_bound_region ( * debruijn, br, first_free_index, scopes)
244
245
} else {
@@ -421,7 +422,13 @@ where
421
422
// Forbid inference variables in the RHS.
422
423
bug ! ( "unexpected inference var {:?}" , b)
423
424
} else {
424
- self . relate_ty_var ( vid, a)
425
+ // We swap the order of `a` and `b` in the call to
426
+ // `relate_ty_var` below, so swap the corresponding scopes
427
+ // as well.
428
+ std:: mem:: swap ( & mut self . a_scopes , & mut self . b_scopes ) ;
429
+ let res = self . relate_ty_var ( vid, a) ;
430
+ std:: mem:: swap ( & mut self . a_scopes , & mut self . b_scopes ) ;
431
+ res
425
432
}
426
433
}
427
434
@@ -436,7 +443,12 @@ where
436
443
( _, & ty:: Projection ( projection_ty) )
437
444
if D :: normalization ( ) == NormalizationStrategy :: Lazy =>
438
445
{
439
- Ok ( self . relate_projection_ty ( projection_ty, a) )
446
+ // Swap the respective scopes of `a` and `b` (see comment
447
+ // above).
448
+ std:: mem:: swap ( & mut self . a_scopes , & mut self . b_scopes ) ;
449
+ let res = self . relate_projection_ty ( projection_ty, a) ;
450
+ std:: mem:: swap ( & mut self . a_scopes , & mut self . b_scopes ) ;
451
+ Ok ( res)
440
452
}
441
453
442
454
_ => {
0 commit comments