Skip to content

Commit ad7e63b

Browse files
committed
Unify walk_param_bound
1 parent 7490067 commit ad7e63b

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
@@ -897,6 +897,25 @@ macro_rules! make_ast_visitor {
897897
return_result!(V)
898898
}
899899

900+
pub fn walk_param_bound<$($lt,)? V: $trait$(<$lt>)?>(
901+
vis: &mut V,
902+
bound: ref_t!(GenericBound)
903+
) -> result!(V) {
904+
match bound {
905+
GenericBound::Trait(typ, _modifier) => {
906+
try_v!(vis.visit_poly_trait_ref(typ));
907+
}
908+
GenericBound::Outlives(lifetime) => {
909+
try_v!(vis.visit_lifetime(lifetime, LifetimeCtxt::Bound));
910+
}
911+
GenericBound::Use(args, span) => {
912+
visit_list!(vis, visit_precise_capturing_arg, args);
913+
try_v!(visit_span!(vis, span))
914+
}
915+
}
916+
return_result!(V)
917+
}
918+
900919
make_walk_flat_map!{Arm, walk_flat_map_arm, visit_arm}
901920
make_walk_flat_map!{Attribute, walk_flat_map_attribute, visit_attribute}
902921
make_walk_flat_map!{ExprField, walk_flat_map_expr_field, visit_expr_field}
@@ -1308,22 +1327,6 @@ pub mod visit {
13081327
}
13091328
}
13101329

1311-
pub fn walk_param_bound<'a, V: Visitor<'a>>(
1312-
visitor: &mut V,
1313-
bound: &'a GenericBound,
1314-
) -> V::Result {
1315-
match bound {
1316-
GenericBound::Trait(typ, _modifier) => visitor.visit_poly_trait_ref(typ),
1317-
GenericBound::Outlives(lifetime) => {
1318-
visitor.visit_lifetime(lifetime, LifetimeCtxt::Bound)
1319-
}
1320-
GenericBound::Use(args, _span) => {
1321-
walk_list!(visitor, visit_precise_capturing_arg, args);
1322-
V::Result::output()
1323-
}
1324-
}
1325-
}
1326-
13271330
pub fn walk_precise_capturing_arg<'a, V: Visitor<'a>>(
13281331
visitor: &mut V,
13291332
arg: &'a PreciseCapturingArg,
@@ -2207,19 +2210,6 @@ pub mod mut_visit {
22072210
}
22082211
}
22092212

2210-
fn walk_param_bound<T: MutVisitor>(vis: &mut T, pb: &mut GenericBound) {
2211-
match pb {
2212-
GenericBound::Trait(ty, _modifier) => vis.visit_poly_trait_ref(ty),
2213-
GenericBound::Outlives(lifetime) => walk_lifetime(vis, lifetime),
2214-
GenericBound::Use(args, span) => {
2215-
for arg in args {
2216-
vis.visit_precise_capturing_arg(arg);
2217-
}
2218-
vis.visit_span(span);
2219-
}
2220-
}
2221-
}
2222-
22232213
fn walk_precise_capturing_arg<T: MutVisitor>(vis: &mut T, arg: &mut PreciseCapturingArg) {
22242214
match arg {
22252215
PreciseCapturingArg::Lifetime(lt) => {

0 commit comments

Comments
 (0)