Extract record_elided_anchor
This commit is contained in:
parent
9f10f589a7
commit
f8b1b2bdfb
@ -29,6 +29,17 @@ fn record_lifetime_use(&mut self, lifetime: Lifetime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn record_elided_anchor(&mut self, node_id: NodeId, span: Span) {
|
||||||
|
if let Some(LifetimeRes::ElidedAnchor { start, end }) =
|
||||||
|
self.resolver.get_lifetime_res(node_id)
|
||||||
|
{
|
||||||
|
for i in start..end {
|
||||||
|
let lifetime = Lifetime { id: i, ident: Ident::new(kw::UnderscoreLifetime, span) };
|
||||||
|
self.record_lifetime_use(lifetime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ast> Visitor<'ast> for LifetimeCollectVisitor<'ast> {
|
impl<'ast> Visitor<'ast> for LifetimeCollectVisitor<'ast> {
|
||||||
@ -37,15 +48,7 @@ fn visit_lifetime(&mut self, lifetime: &'ast Lifetime, _: LifetimeCtxt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn visit_path_segment(&mut self, path_span: Span, path_segment: &'ast PathSegment) {
|
fn visit_path_segment(&mut self, path_span: Span, path_segment: &'ast PathSegment) {
|
||||||
if let Some(LifetimeRes::ElidedAnchor { start, end }) =
|
self.record_elided_anchor(path_segment.id, path_span);
|
||||||
self.resolver.get_lifetime_res(path_segment.id)
|
|
||||||
{
|
|
||||||
for i in start..end {
|
|
||||||
let lifetime =
|
|
||||||
Lifetime { id: i, ident: Ident::new(kw::UnderscoreLifetime, path_span) };
|
|
||||||
self.record_lifetime_use(lifetime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
visit::walk_path_segment(self, path_span, path_segment);
|
visit::walk_path_segment(self, path_span, path_segment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,15 +68,7 @@ fn visit_ty(&mut self, t: &'ast Ty) {
|
|||||||
self.current_binders.pop();
|
self.current_binders.pop();
|
||||||
}
|
}
|
||||||
TyKind::Rptr(None, _) => {
|
TyKind::Rptr(None, _) => {
|
||||||
if let Some(LifetimeRes::ElidedAnchor { start, end }) =
|
self.record_elided_anchor(t.id, t.span);
|
||||||
self.resolver.get_lifetime_res(t.id)
|
|
||||||
{
|
|
||||||
for i in start..end {
|
|
||||||
let lifetime =
|
|
||||||
Lifetime { id: i, ident: Ident::new(kw::UnderscoreLifetime, t.span) };
|
|
||||||
self.record_lifetime_use(lifetime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
visit::walk_ty(self, t);
|
visit::walk_ty(self, t);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
Loading…
Reference in New Issue
Block a user