Skip to content

Commit 6b8de1d

Browse files
committed
Unify walk_generic_argz
1 parent 628b7d4 commit 6b8de1d

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

compiler/rustc_ast/src/visitors.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,18 @@ macro_rules! make_ast_visitor {
509509
return_result!(V)
510510
}
511511

512+
pub fn walk_generic_arg<$($lt,)? V: $trait$(<$lt>)?>(
513+
vis: &mut V,
514+
arg: ref_t!(GenericArg)
515+
) -> result!(V) {
516+
match arg {
517+
GenericArg::Lifetime(lt) => try_v!(vis.visit_lifetime(lt, LifetimeCtxt::GenericArg)),
518+
GenericArg::Type(ty) => try_v!(vis.visit_ty(ty)),
519+
GenericArg::Const(ct) => try_v!(vis.visit_anon_const(ct)),
520+
}
521+
return_result!(V)
522+
}
523+
512524
pub fn walk_generic_args<$($lt,)? V: $trait$(<$lt>)?>(
513525
vis: &mut V,
514526
generic_args: ref_t!(GenericArgs)
@@ -1124,17 +1136,6 @@ pub mod visit {
11241136
V::Result::output()
11251137
}
11261138

1127-
pub fn walk_generic_arg<'a, V>(visitor: &mut V, generic_arg: &'a GenericArg) -> V::Result
1128-
where
1129-
V: Visitor<'a>,
1130-
{
1131-
match generic_arg {
1132-
GenericArg::Lifetime(lt) => visitor.visit_lifetime(lt, LifetimeCtxt::GenericArg),
1133-
GenericArg::Type(ty) => visitor.visit_ty(ty),
1134-
GenericArg::Const(ct) => visitor.visit_anon_const(ct),
1135-
}
1136-
}
1137-
11381139
pub fn walk_assoc_item_constraint<'a, V: Visitor<'a>>(
11391140
visitor: &mut V,
11401141
constraint: &'a AssocItemConstraint,
@@ -1840,14 +1841,6 @@ pub mod mut_visit {
18401841
smallvec![variant]
18411842
}
18421843

1843-
fn walk_generic_arg<T: MutVisitor>(vis: &mut T, arg: &mut GenericArg) {
1844-
match arg {
1845-
GenericArg::Lifetime(lt) => vis.visit_lifetime(lt, LifetimeCtxt::GenericArg),
1846-
GenericArg::Type(ty) => vis.visit_ty(ty),
1847-
GenericArg::Const(ct) => vis.visit_anon_const(ct),
1848-
}
1849-
}
1850-
18511844
fn walk_attribute<T: MutVisitor>(vis: &mut T, attr: &mut Attribute) {
18521845
let Attribute { kind, id: _, style: _, span } = attr;
18531846
match kind {

0 commit comments

Comments
 (0)