@@ -573,11 +573,17 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
573
573
// give, we will reverse the IndexMap after early captures.
574
574
let mut late_depth = 0 ;
575
575
let mut scope = self . scope ;
576
+ let mut crossed_late_boundary = None ;
576
577
let mut opaque_capture_scopes = vec ! [ ( opaque. def_id, & captures) ] ;
577
578
loop {
578
579
match * scope {
579
580
Scope :: Binder { ref bound_vars, scope_type, s, .. } => {
580
581
for ( & original_lifetime, & def) in bound_vars. iter ( ) . rev ( ) {
582
+ if let ResolvedArg :: LateBound ( ..) = def
583
+ && crossed_late_boundary. is_some ( )
584
+ {
585
+ continue ;
586
+ }
581
587
if let DefKind :: LifetimeParam = self . tcx . def_kind ( original_lifetime) {
582
588
let def = def. shifted ( late_depth) ;
583
589
let ident = lifetime_ident ( original_lifetime) ;
@@ -618,8 +624,12 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
618
624
619
625
Scope :: ObjectLifetimeDefault { s, .. }
620
626
| Scope :: Supertrait { s, .. }
621
- | Scope :: TraitRefBoundary { s, .. }
622
- | Scope :: LateBoundary { s, .. } => {
627
+ | Scope :: TraitRefBoundary { s, .. } => {
628
+ scope = s;
629
+ }
630
+
631
+ Scope :: LateBoundary { s, what, .. } => {
632
+ crossed_late_boundary = Some ( what) ;
623
633
scope = s;
624
634
}
625
635
}
0 commit comments