Remove NEW_COLLECT_LIFETIMES env var
This commit is contained in:
parent
399609e841
commit
fac763168f
1 changed files with 82 additions and 104 deletions
|
@ -1377,125 +1377,103 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
let hir_bounds = if origin == hir::OpaqueTyOrigin::TyAlias {
|
let hir_bounds = if origin == hir::OpaqueTyOrigin::TyAlias {
|
||||||
lctx.lower_param_bounds(bounds, itctx, true)
|
lctx.lower_param_bounds(bounds, itctx, true)
|
||||||
} else {
|
} else {
|
||||||
if std::env::var("NEW_COLLECT_LIFETIMES").is_ok() {
|
debug!(?lctx.captured_lifetimes);
|
||||||
debug!(?lctx.captured_lifetimes);
|
|
||||||
|
|
||||||
let lifetime_stash = std::mem::replace(
|
let lifetime_stash = std::mem::replace(
|
||||||
&mut lctx.captured_lifetimes,
|
&mut lctx.captured_lifetimes,
|
||||||
Some(LifetimeCaptureContext {
|
Some(LifetimeCaptureContext {
|
||||||
parent_def_id: opaque_ty_def_id,
|
parent_def_id: opaque_ty_def_id,
|
||||||
captures: std::mem::take(&mut collected_lifetimes),
|
captures: std::mem::take(&mut collected_lifetimes),
|
||||||
binders_to_ignore: Default::default(),
|
binders_to_ignore: Default::default(),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
let (lifetimes_in_bounds, binders_to_ignore) = ast::lifetimes_in_bounds(bounds);
|
let (lifetimes_in_bounds, binders_to_ignore) = ast::lifetimes_in_bounds(bounds);
|
||||||
debug!(?lifetimes_in_bounds);
|
debug!(?lifetimes_in_bounds);
|
||||||
debug!(?binders_to_ignore);
|
debug!(?binders_to_ignore);
|
||||||
|
|
||||||
for lifetime in &lifetimes_in_bounds {
|
for lifetime in &lifetimes_in_bounds {
|
||||||
let ident = lifetime.ident;
|
let ident = lifetime.ident;
|
||||||
let span = ident.span;
|
let span = ident.span;
|
||||||
|
|
||||||
let res = lctx
|
let res =
|
||||||
.resolver
|
lctx.resolver.get_lifetime_res(lifetime.id).unwrap_or(LifetimeRes::Error);
|
||||||
.get_lifetime_res(lifetime.id)
|
debug!(?res);
|
||||||
.unwrap_or(LifetimeRes::Error);
|
|
||||||
debug!(?res);
|
|
||||||
|
|
||||||
if let Some(mut captured_lifetimes) = lctx.captured_lifetimes.take() {
|
if let Some(mut captured_lifetimes) = lctx.captured_lifetimes.take() {
|
||||||
match res {
|
match res {
|
||||||
LifetimeRes::Param { param, binder } => {
|
LifetimeRes::Param { param, binder } => {
|
||||||
if !captured_lifetimes.binders_to_ignore.contains(&binder)
|
if !captured_lifetimes.binders_to_ignore.contains(&binder)
|
||||||
&& !binders_to_ignore
|
&& !binders_to_ignore
|
||||||
.get(&lifetime.id)
|
.get(&lifetime.id)
|
||||||
.unwrap_or(&Vec::new())
|
.unwrap_or(&Vec::new())
|
||||||
.contains(&binder)
|
.contains(&binder)
|
||||||
{
|
{
|
||||||
match captured_lifetimes.captures.entry(param) {
|
match captured_lifetimes.captures.entry(param) {
|
||||||
Entry::Occupied(_) => {}
|
Entry::Occupied(_) => {}
|
||||||
Entry::Vacant(v) => {
|
Entry::Vacant(v) => {
|
||||||
let node_id = lctx.next_node_id();
|
let node_id = lctx.next_node_id();
|
||||||
let name = ParamName::Plain(ident);
|
let name = ParamName::Plain(ident);
|
||||||
|
|
||||||
lctx.create_def(
|
lctx.create_def(
|
||||||
captured_lifetimes.parent_def_id,
|
captured_lifetimes.parent_def_id,
|
||||||
node_id,
|
node_id,
|
||||||
DefPathData::LifetimeNs(name.ident().name),
|
DefPathData::LifetimeNs(name.ident().name),
|
||||||
);
|
);
|
||||||
|
|
||||||
v.insert((span, node_id, name, res));
|
v.insert((span, node_id, name, res));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LifetimeRes::Fresh { param, binder } => {
|
|
||||||
debug_assert_eq!(ident.name, kw::UnderscoreLifetime);
|
|
||||||
if !captured_lifetimes.binders_to_ignore.contains(&binder)
|
|
||||||
&& !binders_to_ignore
|
|
||||||
.get(&lifetime.id)
|
|
||||||
.unwrap_or(&Vec::new())
|
|
||||||
.contains(&binder)
|
|
||||||
{
|
|
||||||
let param = lctx.local_def_id(param);
|
|
||||||
match captured_lifetimes.captures.entry(param) {
|
|
||||||
Entry::Occupied(_) => {}
|
|
||||||
Entry::Vacant(v) => {
|
|
||||||
let node_id = lctx.next_node_id();
|
|
||||||
|
|
||||||
let name = ParamName::Fresh;
|
|
||||||
|
|
||||||
lctx.create_def(
|
|
||||||
captured_lifetimes.parent_def_id,
|
|
||||||
node_id,
|
|
||||||
DefPathData::LifetimeNs(kw::UnderscoreLifetime),
|
|
||||||
);
|
|
||||||
|
|
||||||
v.insert((span, node_id, name, res));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LifetimeRes::Infer | LifetimeRes::Static | LifetimeRes::Error => {}
|
|
||||||
|
|
||||||
res => panic!(
|
|
||||||
"Unexpected lifetime resolution {:?} for {:?} at {:?}",
|
|
||||||
res, lifetime.ident, lifetime.ident.span
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lctx.captured_lifetimes = Some(captured_lifetimes);
|
LifetimeRes::Fresh { param, binder } => {
|
||||||
|
debug_assert_eq!(ident.name, kw::UnderscoreLifetime);
|
||||||
|
if !captured_lifetimes.binders_to_ignore.contains(&binder)
|
||||||
|
&& !binders_to_ignore
|
||||||
|
.get(&lifetime.id)
|
||||||
|
.unwrap_or(&Vec::new())
|
||||||
|
.contains(&binder)
|
||||||
|
{
|
||||||
|
let param = lctx.local_def_id(param);
|
||||||
|
match captured_lifetimes.captures.entry(param) {
|
||||||
|
Entry::Occupied(_) => {}
|
||||||
|
Entry::Vacant(v) => {
|
||||||
|
let node_id = lctx.next_node_id();
|
||||||
|
|
||||||
|
let name = ParamName::Fresh;
|
||||||
|
|
||||||
|
lctx.create_def(
|
||||||
|
captured_lifetimes.parent_def_id,
|
||||||
|
node_id,
|
||||||
|
DefPathData::LifetimeNs(kw::UnderscoreLifetime),
|
||||||
|
);
|
||||||
|
|
||||||
|
v.insert((span, node_id, name, res));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LifetimeRes::Infer | LifetimeRes::Static | LifetimeRes::Error => {}
|
||||||
|
|
||||||
|
res => panic!(
|
||||||
|
"Unexpected lifetime resolution {:?} for {:?} at {:?}",
|
||||||
|
res, lifetime.ident, lifetime.ident.span
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lctx.captured_lifetimes = Some(captured_lifetimes);
|
||||||
}
|
}
|
||||||
|
|
||||||
let ret = lctx.lower_param_bounds(bounds, itctx, false);
|
|
||||||
|
|
||||||
let ctxt =
|
|
||||||
std::mem::replace(&mut lctx.captured_lifetimes, lifetime_stash).unwrap();
|
|
||||||
|
|
||||||
collected_lifetimes = ctxt.captures;
|
|
||||||
|
|
||||||
ret
|
|
||||||
} else {
|
|
||||||
let lifetime_stash = std::mem::replace(
|
|
||||||
&mut lctx.captured_lifetimes,
|
|
||||||
Some(LifetimeCaptureContext {
|
|
||||||
parent_def_id: opaque_ty_def_id,
|
|
||||||
captures: std::mem::take(&mut collected_lifetimes),
|
|
||||||
binders_to_ignore: Default::default(),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
let ret = lctx.lower_param_bounds(bounds, itctx, true);
|
|
||||||
|
|
||||||
let ctxt =
|
|
||||||
std::mem::replace(&mut lctx.captured_lifetimes, lifetime_stash).unwrap();
|
|
||||||
collected_lifetimes = ctxt.captures;
|
|
||||||
|
|
||||||
ret
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let ret = lctx.lower_param_bounds(bounds, itctx, false);
|
||||||
|
|
||||||
|
let ctxt = std::mem::replace(&mut lctx.captured_lifetimes, lifetime_stash).unwrap();
|
||||||
|
|
||||||
|
collected_lifetimes = ctxt.captures;
|
||||||
|
|
||||||
|
ret
|
||||||
};
|
};
|
||||||
debug!(?collected_lifetimes);
|
debug!(?collected_lifetimes);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue