@@ -1482,7 +1482,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
1482
1482
if let Some ( & ( _, res) ) = rib. bindings . get ( & normalized_ident) {
1483
1483
self . record_lifetime_res ( lifetime. id , res, LifetimeElisionCandidate :: Named ) ;
1484
1484
1485
- if let LifetimeRes :: Param { param, .. } = res {
1485
+ if let LifetimeRes :: Param { param, binder } = res {
1486
1486
match self . lifetime_uses . entry ( param) {
1487
1487
Entry :: Vacant ( v) => {
1488
1488
debug ! ( "First use of {:?} at {:?}" , res, ident. span) ;
@@ -1496,10 +1496,16 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
1496
1496
LifetimeRibKind :: Item
1497
1497
| LifetimeRibKind :: AnonymousReportError
1498
1498
| LifetimeRibKind :: ElisionFailure => Some ( LifetimeUseSet :: Many ) ,
1499
- // An anonymous lifetime is legal here, go ahead.
1500
- LifetimeRibKind :: AnonymousCreateParameter { .. } => {
1501
- Some ( LifetimeUseSet :: One { use_span : ident. span , use_ctxt } )
1502
- }
1499
+ // An anonymous lifetime is legal here, and bound to the right
1500
+ // place, go ahead.
1501
+ LifetimeRibKind :: AnonymousCreateParameter {
1502
+ binder : anon_binder,
1503
+ ..
1504
+ } => Some ( if binder == anon_binder {
1505
+ LifetimeUseSet :: One { use_span : ident. span , use_ctxt }
1506
+ } else {
1507
+ LifetimeUseSet :: Many
1508
+ } ) ,
1503
1509
// Only report if eliding the lifetime would have the same
1504
1510
// semantics.
1505
1511
LifetimeRibKind :: Elided ( r) => Some ( if res == r {
0 commit comments