From e426f262fd8ed1f1ea1d09834d365b41548e21d1 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 9 Jul 2024 10:28:09 +0000 Subject: [PATCH] Split up `visit_path` so `MutVisitor` has a `path_segment` method just like the immutable visitor --- compiler/rustc_ast/src/mut_visit.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 999ef3a01cd..f84929f5299 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -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>) { noop_visit_qself(qs, self); } @@ -554,11 +558,16 @@ fn noop_visit_ident(Ident { name: _, span }: &mut Ident, vis: &mu vis.visit_span(span); } +fn noop_visit_path_segment(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(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);