Skip to content

Commit fac7631

Browse files
committed
Remove NEW_COLLECT_LIFETIMES env var
1 parent 399609e commit fac7631

File tree

1 file changed

+82
-104
lines changed
  • compiler/rustc_ast_lowering/src

1 file changed

+82
-104
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 82 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,125 +1377,103 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13771377
let hir_bounds = if origin == hir::OpaqueTyOrigin::TyAlias {
13781378
lctx.lower_param_bounds(bounds, itctx, true)
13791379
} 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));
14291425
}
14301426
}
14311427
}
1428+
}
14321429

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));
14571453
}
14581454
}
14591455
}
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-
),
14671456
}
14681457

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 => {}
14741459

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+
}
14771465

1478-
collected_lifetimes = ctxt.captures;
1466+
lctx.captured_lifetimes = Some(captured_lifetimes);
1467+
}
1468+
}
14791469

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);
14901471

1491-
let ret = lctx.lower_param_bounds(bounds, itctx, true);
1472+
let ctxt = std::mem::replace(&mut lctx.captured_lifetimes, lifetime_stash).unwrap();
14921473

1493-
let ctxt =
1494-
std::mem::replace(&mut lctx.captured_lifetimes, lifetime_stash).unwrap();
1495-
collected_lifetimes = ctxt.captures;
1474+
collected_lifetimes = ctxt.captures;
14961475

1497-
ret
1498-
}
1476+
ret
14991477
};
15001478
debug!(?collected_lifetimes);
15011479

0 commit comments

Comments
 (0)