Split up visit_path so MutVisitor has a path_segment method just like the immutable visitor

This commit is contained in:
Oli Scherer 2024-07-09 10:28:09 +00:00
parent 545553ca4f
commit e426f262fd

View File

@ -207,6 +207,10 @@ fn visit_path(&mut self, p: &mut Path) {
noop_visit_path(p, self);
}
fn visit_path_segment(&mut self, p: &mut PathSegment) {
noop_visit_path_segment(p, self)
}
fn visit_qself(&mut self, qs: &mut Option<P<QSelf>>) {
noop_visit_qself(qs, self);
}
@ -554,11 +558,16 @@ fn noop_visit_ident<T: MutVisitor>(Ident { name: _, span }: &mut Ident, vis: &mu
vis.visit_span(span);
}
fn noop_visit_path_segment<T: MutVisitor>(segment: &mut PathSegment, vis: &mut T) {
let PathSegment { ident, id, args } = segment;
vis.visit_id(id);
vis.visit_ident(ident);
visit_opt(args, |args| vis.visit_generic_args(args));
}
fn noop_visit_path<T: MutVisitor>(Path { segments, span, tokens }: &mut Path, vis: &mut T) {
for PathSegment { ident, id, args } in segments {
vis.visit_id(id);
vis.visit_ident(ident);
visit_opt(args, |args| vis.visit_generic_args(args));
for segment in segments {
vis.visit_path_segment(segment);
}
visit_lazy_tts(tokens, vis);
vis.visit_span(span);