Skip to content

Commit 02df8e8

Browse files
committed
Unify walk_param_bound
1 parent 6b8de1d commit 02df8e8

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
@@ -539,6 +539,25 @@ macro_rules! make_ast_visitor {
539539
return_result!(V)
540540
}
541541

542+
pub fn walk_param_bound<$($lt,)? V: $trait$(<$lt>)?>(
543+
vis: &mut V,
544+
bound: ref_t!(GenericBound)
545+
) -> result!(V) {
546+
match bound {
547+
GenericBound::Trait(typ, _modifier) => {
548+
try_v!(vis.visit_poly_trait_ref(typ));
549+
}
550+
GenericBound::Outlives(lifetime) => {
551+
try_v!(vis.visit_lifetime(lifetime, LifetimeCtxt::Bound));
552+
}
553+
GenericBound::Use(args, span) => {
554+
visit_list!(vis, visit_precise_capturing_arg, args);
555+
try_v!(visit_span!(vis, span))
556+
}
557+
}
558+
return_result!(V)
559+
}
560+
542561
pub fn walk_generics<$($lt,)? V: $trait$(<$lt>)?>(
543562
vis: &mut V,
544563
generics: ref_t!(Generics)
@@ -1234,22 +1253,6 @@ pub mod visit {
12341253
}
12351254
}
12361255

1237-
pub fn walk_param_bound<'a, V: Visitor<'a>>(
1238-
visitor: &mut V,
1239-
bound: &'a GenericBound,
1240-
) -> V::Result {
1241-
match bound {
1242-
GenericBound::Trait(typ, _modifier) => visitor.visit_poly_trait_ref(typ),
1243-
GenericBound::Outlives(lifetime) => {
1244-
visitor.visit_lifetime(lifetime, LifetimeCtxt::Bound)
1245-
}
1246-
GenericBound::Use(args, _span) => {
1247-
walk_list!(visitor, visit_precise_capturing_arg, args);
1248-
V::Result::output()
1249-
}
1250-
}
1251-
}
1252-
12531256
pub fn walk_precise_capturing_arg<'a, V: Visitor<'a>>(
12541257
visitor: &mut V,
12551258
arg: &'a PreciseCapturingArg,
@@ -2106,19 +2109,6 @@ pub mod mut_visit {
21062109
}
21072110
}
21082111

2109-
fn walk_param_bound<T: MutVisitor>(vis: &mut T, pb: &mut GenericBound) {
2110-
match pb {
2111-
GenericBound::Trait(ty, _modifier) => vis.visit_poly_trait_ref(ty),
2112-
GenericBound::Outlives(lifetime) => vis.visit_lifetime(lifetime, LifetimeCtxt::Bound),
2113-
GenericBound::Use(args, span) => {
2114-
for arg in args {
2115-
vis.visit_precise_capturing_arg(arg);
2116-
}
2117-
vis.visit_span(span);
2118-
}
2119-
}
2120-
}
2121-
21222112
fn walk_precise_capturing_arg<T: MutVisitor>(vis: &mut T, arg: &mut PreciseCapturingArg) {
21232113
match arg {
21242114
PreciseCapturingArg::Lifetime(lt) => {

0 commit comments

Comments
 (0)