@@ -1377,125 +1377,103 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1377
1377
let hir_bounds = if origin == hir:: OpaqueTyOrigin :: TyAlias {
1378
1378
lctx. lower_param_bounds ( bounds, itctx, true )
1379
1379
} else {
1380
- if std:: env:: var ( "NEW_COLLECT_LIFETIMES" ) . is_ok ( ) {
1381
- debug ! ( ?lctx. captured_lifetimes) ;
1382
-
1383
- let lifetime_stash = std:: mem:: replace (
1384
- & mut lctx. captured_lifetimes ,
1385
- Some ( LifetimeCaptureContext {
1386
- parent_def_id : opaque_ty_def_id,
1387
- captures : std:: mem:: take ( & mut collected_lifetimes) ,
1388
- binders_to_ignore : Default :: default ( ) ,
1389
- } ) ,
1390
- ) ;
1391
-
1392
- let ( lifetimes_in_bounds, binders_to_ignore) = ast:: lifetimes_in_bounds ( bounds) ;
1393
- debug ! ( ?lifetimes_in_bounds) ;
1394
- debug ! ( ?binders_to_ignore) ;
1395
-
1396
- for lifetime in & lifetimes_in_bounds {
1397
- let ident = lifetime. ident ;
1398
- let span = ident. span ;
1399
-
1400
- let res = lctx
1401
- . resolver
1402
- . get_lifetime_res ( lifetime. id )
1403
- . unwrap_or ( LifetimeRes :: Error ) ;
1404
- debug ! ( ?res) ;
1405
-
1406
- if let Some ( mut captured_lifetimes) = lctx. captured_lifetimes . take ( ) {
1407
- match res {
1408
- LifetimeRes :: Param { param, binder } => {
1409
- if !captured_lifetimes. binders_to_ignore . contains ( & binder)
1410
- && !binders_to_ignore
1411
- . get ( & lifetime. id )
1412
- . unwrap_or ( & Vec :: new ( ) )
1413
- . contains ( & binder)
1414
- {
1415
- match captured_lifetimes. captures . entry ( param) {
1416
- Entry :: Occupied ( _) => { }
1417
- Entry :: Vacant ( v) => {
1418
- let node_id = lctx. next_node_id ( ) ;
1419
- let name = ParamName :: Plain ( ident) ;
1420
-
1421
- lctx. create_def (
1422
- captured_lifetimes. parent_def_id ,
1423
- node_id,
1424
- DefPathData :: LifetimeNs ( name. ident ( ) . name ) ,
1425
- ) ;
1426
-
1427
- v. insert ( ( span, node_id, name, res) ) ;
1428
- }
1380
+ debug ! ( ?lctx. captured_lifetimes) ;
1381
+
1382
+ let lifetime_stash = std:: mem:: replace (
1383
+ & mut lctx. captured_lifetimes ,
1384
+ Some ( LifetimeCaptureContext {
1385
+ parent_def_id : opaque_ty_def_id,
1386
+ captures : std:: mem:: take ( & mut collected_lifetimes) ,
1387
+ binders_to_ignore : Default :: default ( ) ,
1388
+ } ) ,
1389
+ ) ;
1390
+
1391
+ let ( lifetimes_in_bounds, binders_to_ignore) = ast:: lifetimes_in_bounds ( bounds) ;
1392
+ debug ! ( ?lifetimes_in_bounds) ;
1393
+ debug ! ( ?binders_to_ignore) ;
1394
+
1395
+ for lifetime in & lifetimes_in_bounds {
1396
+ let ident = lifetime. ident ;
1397
+ let span = ident. span ;
1398
+
1399
+ let res =
1400
+ lctx. resolver . get_lifetime_res ( lifetime. id ) . unwrap_or ( LifetimeRes :: Error ) ;
1401
+ debug ! ( ?res) ;
1402
+
1403
+ if let Some ( mut captured_lifetimes) = lctx. captured_lifetimes . take ( ) {
1404
+ match res {
1405
+ LifetimeRes :: Param { param, binder } => {
1406
+ if !captured_lifetimes. binders_to_ignore . contains ( & binder)
1407
+ && !binders_to_ignore
1408
+ . get ( & lifetime. id )
1409
+ . unwrap_or ( & Vec :: new ( ) )
1410
+ . contains ( & binder)
1411
+ {
1412
+ match captured_lifetimes. captures . entry ( param) {
1413
+ Entry :: Occupied ( _) => { }
1414
+ Entry :: Vacant ( v) => {
1415
+ let node_id = lctx. next_node_id ( ) ;
1416
+ let name = ParamName :: Plain ( ident) ;
1417
+
1418
+ lctx. create_def (
1419
+ captured_lifetimes. parent_def_id ,
1420
+ node_id,
1421
+ DefPathData :: LifetimeNs ( name. ident ( ) . name ) ,
1422
+ ) ;
1423
+
1424
+ v. insert ( ( span, node_id, name, res) ) ;
1429
1425
}
1430
1426
}
1431
1427
}
1428
+ }
1432
1429
1433
- LifetimeRes :: Fresh { param, binder } => {
1434
- debug_assert_eq ! ( ident. name, kw:: UnderscoreLifetime ) ;
1435
- if !captured_lifetimes. binders_to_ignore . contains ( & binder)
1436
- && !binders_to_ignore
1437
- . get ( & lifetime. id )
1438
- . unwrap_or ( & Vec :: new ( ) )
1439
- . contains ( & binder)
1440
- {
1441
- let param = lctx. local_def_id ( param) ;
1442
- match captured_lifetimes. captures . entry ( param) {
1443
- Entry :: Occupied ( _) => { }
1444
- Entry :: Vacant ( v) => {
1445
- let node_id = lctx. next_node_id ( ) ;
1446
-
1447
- let name = ParamName :: Fresh ;
1448
-
1449
- lctx. create_def (
1450
- captured_lifetimes. parent_def_id ,
1451
- node_id,
1452
- DefPathData :: LifetimeNs ( kw:: UnderscoreLifetime ) ,
1453
- ) ;
1454
-
1455
- v. insert ( ( span, node_id, name, res) ) ;
1456
- }
1430
+ LifetimeRes :: Fresh { param, binder } => {
1431
+ debug_assert_eq ! ( ident. name, kw:: UnderscoreLifetime ) ;
1432
+ if !captured_lifetimes. binders_to_ignore . contains ( & binder)
1433
+ && !binders_to_ignore
1434
+ . get ( & lifetime. id )
1435
+ . unwrap_or ( & Vec :: new ( ) )
1436
+ . contains ( & binder)
1437
+ {
1438
+ let param = lctx. local_def_id ( param) ;
1439
+ match captured_lifetimes. captures . entry ( param) {
1440
+ Entry :: Occupied ( _) => { }
1441
+ Entry :: Vacant ( v) => {
1442
+ let node_id = lctx. next_node_id ( ) ;
1443
+
1444
+ let name = ParamName :: Fresh ;
1445
+
1446
+ lctx. create_def (
1447
+ captured_lifetimes. parent_def_id ,
1448
+ node_id,
1449
+ DefPathData :: LifetimeNs ( kw:: UnderscoreLifetime ) ,
1450
+ ) ;
1451
+
1452
+ v. insert ( ( span, node_id, name, res) ) ;
1457
1453
}
1458
1454
}
1459
1455
}
1460
-
1461
- LifetimeRes :: Infer | LifetimeRes :: Static | LifetimeRes :: Error => { }
1462
-
1463
- res => panic ! (
1464
- "Unexpected lifetime resolution {:?} for {:?} at {:?}" ,
1465
- res, lifetime. ident, lifetime. ident. span
1466
- ) ,
1467
1456
}
1468
1457
1469
- lctx. captured_lifetimes = Some ( captured_lifetimes) ;
1470
- }
1471
- }
1472
-
1473
- let ret = lctx. lower_param_bounds ( bounds, itctx, false ) ;
1458
+ LifetimeRes :: Infer | LifetimeRes :: Static | LifetimeRes :: Error => { }
1474
1459
1475
- let ctxt =
1476
- std:: mem:: replace ( & mut lctx. captured_lifetimes , lifetime_stash) . unwrap ( ) ;
1460
+ res => panic ! (
1461
+ "Unexpected lifetime resolution {:?} for {:?} at {:?}" ,
1462
+ res, lifetime. ident, lifetime. ident. span
1463
+ ) ,
1464
+ }
1477
1465
1478
- collected_lifetimes = ctxt. captures ;
1466
+ lctx. captured_lifetimes = Some ( captured_lifetimes) ;
1467
+ }
1468
+ }
1479
1469
1480
- ret
1481
- } else {
1482
- let lifetime_stash = std:: mem:: replace (
1483
- & mut lctx. captured_lifetimes ,
1484
- Some ( LifetimeCaptureContext {
1485
- parent_def_id : opaque_ty_def_id,
1486
- captures : std:: mem:: take ( & mut collected_lifetimes) ,
1487
- binders_to_ignore : Default :: default ( ) ,
1488
- } ) ,
1489
- ) ;
1470
+ let ret = lctx. lower_param_bounds ( bounds, itctx, false ) ;
1490
1471
1491
- let ret = lctx. lower_param_bounds ( bounds , itctx , true ) ;
1472
+ let ctxt = std :: mem :: replace ( & mut lctx. captured_lifetimes , lifetime_stash ) . unwrap ( ) ;
1492
1473
1493
- let ctxt =
1494
- std:: mem:: replace ( & mut lctx. captured_lifetimes , lifetime_stash) . unwrap ( ) ;
1495
- collected_lifetimes = ctxt. captures ;
1474
+ collected_lifetimes = ctxt. captures ;
1496
1475
1497
- ret
1498
- }
1476
+ ret
1499
1477
} ;
1500
1478
debug ! ( ?collected_lifetimes) ;
1501
1479
0 commit comments