Skip to content

Commit fbfd761

Browse files
committed
Unify walk_param_bound
1 parent ce8ac21 commit fbfd761

File tree

1 file changed

+19
-29
lines changed

1 file changed

+19
-29
lines changed

compiler/rustc_ast/src/visitors.rs

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,25 @@ macro_rules! make_ast_visitor {
545545
return_result!(V)
546546
}
547547

548+
pub fn walk_param_bound<$($lt,)? V: $trait$(<$lt>)?>(
549+
vis: &mut V,
550+
bound: ref_t!(GenericBound)
551+
) -> result!(V) {
552+
match bound {
553+
GenericBound::Trait(typ, _modifier) => {
554+
try_v!(vis.visit_poly_trait_ref(typ));
555+
}
556+
GenericBound::Outlives(lifetime) => {
557+
try_v!(vis.visit_lifetime(lifetime, LifetimeCtxt::Bound));
558+
}
559+
GenericBound::Use(args, span) => {
560+
visit_list!(vis, visit_precise_capturing_arg, args);
561+
try_v!(visit_span!(vis, span))
562+
}
563+
}
564+
return_result!(V)
565+
}
566+
548567
pub fn walk_generics<$($lt,)? V: $trait$(<$lt>)?>(
549568
vis: &mut V,
550569
generics: ref_t!(Generics)
@@ -1240,22 +1259,6 @@ pub mod visit {
12401259
}
12411260
}
12421261

1243-
pub fn walk_param_bound<'a, V: Visitor<'a>>(
1244-
visitor: &mut V,
1245-
bound: &'a GenericBound,
1246-
) -> V::Result {
1247-
match bound {
1248-
GenericBound::Trait(typ, _modifier) => visitor.visit_poly_trait_ref(typ),
1249-
GenericBound::Outlives(lifetime) => {
1250-
visitor.visit_lifetime(lifetime, LifetimeCtxt::Bound)
1251-
}
1252-
GenericBound::Use(args, _span) => {
1253-
walk_list!(visitor, visit_precise_capturing_arg, args);
1254-
V::Result::output()
1255-
}
1256-
}
1257-
}
1258-
12591262
pub fn walk_precise_capturing_arg<'a, V: Visitor<'a>>(
12601263
visitor: &mut V,
12611264
arg: &'a PreciseCapturingArg,
@@ -2112,19 +2115,6 @@ pub mod mut_visit {
21122115
}
21132116
}
21142117

2115-
fn walk_param_bound<T: MutVisitor>(vis: &mut T, pb: &mut GenericBound) {
2116-
match pb {
2117-
GenericBound::Trait(ty, _modifier) => vis.visit_poly_trait_ref(ty),
2118-
GenericBound::Outlives(lifetime) => vis.visit_lifetime(lifetime, LifetimeCtxt::Bound),
2119-
GenericBound::Use(args, span) => {
2120-
for arg in args {
2121-
vis.visit_precise_capturing_arg(arg);
2122-
}
2123-
vis.visit_span(span);
2124-
}
2125-
}
2126-
}
2127-
21282118
fn walk_precise_capturing_arg<T: MutVisitor>(vis: &mut T, arg: &mut PreciseCapturingArg) {
21292119
match arg {
21302120
PreciseCapturingArg::Lifetime(lt) => {

0 commit comments

Comments
 (0)