Skip to content

Commit 37e942a

Browse files
committed
Unify walk_generic_args
1 parent d6fa139 commit 37e942a

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

compiler/rustc_ast/src/visitors.rs

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,24 @@ macro_rules! make_ast_visitor {
370370
return_result!(V)
371371
}
372372

373+
pub fn walk_generic_args<$($lt,)? V: $trait$(<$lt>)?>(
374+
vis: &mut V,
375+
generic_args: ref_t!(GenericArgs)
376+
) -> result!(V) {
377+
match generic_args {
378+
GenericArgs::AngleBracketed(data) => {
379+
try_v!(vis.visit_angle_bracketed_parameter_data(data));
380+
}
381+
GenericArgs::Parenthesized(data) => {
382+
try_v!(vis.visit_parenthesized_parameter_data(data));
383+
}
384+
GenericArgs::ParenthesizedElided(span) => {
385+
try_v!(visit_span!(vis, span));
386+
}
387+
}
388+
return_result!(V)
389+
}
390+
373391
pub fn walk_ident<$($lt,)? V: $trait$(<$lt>)?>(
374392
vis: &mut V,
375393
ident: ref_t!(Ident)
@@ -819,22 +837,6 @@ pub mod visit {
819837
V::Result::output()
820838
}
821839

822-
pub fn walk_generic_args<'a, V>(visitor: &mut V, generic_args: &'a GenericArgs) -> V::Result
823-
where
824-
V: Visitor<'a>,
825-
{
826-
match generic_args {
827-
GenericArgs::AngleBracketed(args) => {
828-
try_visit!(visitor.visit_angle_bracketed_parameter_data(args));
829-
}
830-
GenericArgs::Parenthesized(args) => {
831-
try_visit!(visitor.visit_parenthesized_parameter_data(args));
832-
}
833-
GenericArgs::ParenthesizedElided(_span) => {}
834-
}
835-
V::Result::output()
836-
}
837-
838840
pub fn walk_generic_arg<'a, V>(visitor: &mut V, generic_arg: &'a GenericArg) -> V::Result
839841
where
840842
V: Visitor<'a>,
@@ -1762,14 +1764,6 @@ pub mod mut_visit {
17621764
})
17631765
}
17641766

1765-
fn walk_generic_args<T: MutVisitor>(vis: &mut T, generic_args: &mut GenericArgs) {
1766-
match generic_args {
1767-
GenericArgs::AngleBracketed(data) => vis.visit_angle_bracketed_parameter_data(data),
1768-
GenericArgs::Parenthesized(data) => vis.visit_parenthesized_parameter_data(data),
1769-
GenericArgs::ParenthesizedElided(span) => vis.visit_span(span),
1770-
}
1771-
}
1772-
17731767
fn walk_generic_arg<T: MutVisitor>(vis: &mut T, arg: &mut GenericArg) {
17741768
match arg {
17751769
GenericArg::Lifetime(lt) => vis.visit_lifetime(lt, LifetimeCtxt::GenericArg),

0 commit comments

Comments
 (0)