Skip to content

Commit bce17bd

Browse files
committed
Unify walk_path_segment
1 parent 15ed907 commit bce17bd

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

compiler/rustc_ast/src/visitors.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,17 @@ macro_rules! make_ast_visitor {
729729
return_result!(V)
730730
}
731731

732+
pub fn walk_path_segment<$($lt,)? V: $trait$(<$lt>)?>(
733+
vis: &mut V,
734+
segment: ref_t!(PathSegment)
735+
) -> result!(V) {
736+
let PathSegment { id, ident, args } = segment;
737+
try_v!(visit_id!(vis, id));
738+
try_v!(visit_ident!(vis, ident));
739+
visit_o!(args, |args| vis.visit_generic_args(args));
740+
return_result!(V)
741+
}
742+
732743
make_walk_flat_map!{Arm, walk_flat_map_arm, visit_arm}
733744
make_walk_flat_map!{Attribute, walk_flat_map_attribute, visit_attribute}
734745
make_walk_flat_map!{ExprField, walk_flat_map_expr_field, visit_expr_field}
@@ -1091,16 +1102,6 @@ pub mod visit {
10911102
V::Result::output()
10921103
}
10931104

1094-
pub fn walk_path_segment<'a, V: Visitor<'a>>(
1095-
visitor: &mut V,
1096-
segment: &'a PathSegment,
1097-
) -> V::Result {
1098-
let PathSegment { ident, id: _, args } = segment;
1099-
try_visit!(visitor.visit_ident(*ident));
1100-
visit_opt!(visitor, visit_generic_args, args);
1101-
V::Result::output()
1102-
}
1103-
11041105
pub fn walk_generic_arg<'a, V>(visitor: &mut V, generic_arg: &'a GenericArg) -> V::Result
11051106
where
11061107
V: Visitor<'a>,
@@ -1909,13 +1910,6 @@ pub mod mut_visit {
19091910
items.flat_map_in_place(|item| vis.flat_map_foreign_item(item));
19101911
}
19111912

1912-
fn walk_path_segment<T: MutVisitor>(vis: &mut T, segment: &mut PathSegment) {
1913-
let PathSegment { ident, id, args } = segment;
1914-
vis.visit_id(id);
1915-
vis.visit_ident(ident);
1916-
visit_opt(args, |args| vis.visit_generic_args(args));
1917-
}
1918-
19191913
fn walk_path<T: MutVisitor>(vis: &mut T, Path { segments, span, tokens }: &mut Path) {
19201914
for segment in segments {
19211915
vis.visit_path_segment(segment);

0 commit comments

Comments
 (0)