Skip to content

Commit af0294e

Browse files
committed
Unify walk_vis
1 parent 648be35 commit af0294e

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

compiler/rustc_ast/src/visitors.rs

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,23 @@ macro_rules! make_ast_visitor {
860860
return_result!(V)
861861
}
862862

863+
pub fn walk_vis<$($lt,)? V: $trait$(<$lt>)?>(
864+
vis: &mut V,
865+
visibility: ref_t!(Visibility)
866+
) -> result!(V) {
867+
let Visibility { kind, span, tokens } = visibility;
868+
match kind {
869+
VisibilityKind::Public | VisibilityKind::Inherited => {}
870+
VisibilityKind::Restricted { path, id, shorthand: _ } => {
871+
try_v!(visit_id!(vis, id));
872+
try_v!(vis.visit_path(path, *id));
873+
}
874+
}
875+
visit_lazy_tts!(vis, tokens);
876+
try_v!(visit_span!(vis, span));
877+
return_result!(V)
878+
}
879+
863880
pub fn walk_where_clause<$($lt,)? V: $trait$(<$lt>)?>(
864881
vis: &mut V,
865882
wc: ref_t!(WhereClause)
@@ -1605,17 +1622,6 @@ pub mod visit {
16051622
visitor.visit_expr_post(expression)
16061623
}
16071624

1608-
pub fn walk_vis<'a, V: Visitor<'a>>(visitor: &mut V, vis: &'a Visibility) -> V::Result {
1609-
let Visibility { kind, span: _, tokens: _ } = vis;
1610-
match kind {
1611-
VisibilityKind::Restricted { path, id, shorthand: _ } => {
1612-
try_visit!(visitor.visit_path(path, *id));
1613-
}
1614-
VisibilityKind::Public | VisibilityKind::Inherited => {}
1615-
}
1616-
V::Result::output()
1617-
}
1618-
16191625
pub fn walk_attribute<'a, V: Visitor<'a>>(visitor: &mut V, attr: &'a Attribute) -> V::Result {
16201626
let Attribute { kind, id: _, style: _, span: _ } = attr;
16211627
match kind {
@@ -2692,19 +2698,6 @@ pub mod mut_visit {
26922698
}
26932699
}
26942700

2695-
fn walk_vis<T: MutVisitor>(vis: &mut T, visibility: &mut Visibility) {
2696-
let Visibility { kind, span, tokens } = visibility;
2697-
match kind {
2698-
VisibilityKind::Public | VisibilityKind::Inherited => {}
2699-
VisibilityKind::Restricted { path, id, shorthand: _ } => {
2700-
vis.visit_id(id);
2701-
vis.visit_path(path, *id);
2702-
}
2703-
}
2704-
visit_lazy_tts(vis, tokens);
2705-
vis.visit_span(span);
2706-
}
2707-
27082701
/// Some value for the AST node that is valid but possibly meaningless. Similar
27092702
/// to `Default` but not intended for wide use. The value will never be used
27102703
/// meaningfully, it exists just to support unwinding in `visit_clobber` in the

0 commit comments

Comments
 (0)