Skip to content

Commit 697e179

Browse files
committed
Unify walk_vis
1 parent 3c513fd commit 697e179

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
@@ -866,6 +866,23 @@ macro_rules! make_ast_visitor {
866866
return_result!(V)
867867
}
868868

869+
pub fn walk_vis<$($lt,)? V: $trait$(<$lt>)?>(
870+
vis: &mut V,
871+
visibility: ref_t!(Visibility)
872+
) -> result!(V) {
873+
let Visibility { kind, span, tokens } = visibility;
874+
match kind {
875+
VisibilityKind::Public | VisibilityKind::Inherited => {}
876+
VisibilityKind::Restricted { path, id, shorthand: _ } => {
877+
try_v!(visit_id!(vis, id));
878+
try_v!(vis.visit_path(path, *id));
879+
}
880+
}
881+
visit_lazy_tts!(vis, tokens);
882+
try_v!(visit_span!(vis, span));
883+
return_result!(V)
884+
}
885+
869886
pub fn walk_where_clause<$($lt,)? V: $trait$(<$lt>)?>(
870887
vis: &mut V,
871888
wc: ref_t!(WhereClause)
@@ -1611,17 +1628,6 @@ pub mod visit {
16111628
visitor.visit_expr_post(expression)
16121629
}
16131630

1614-
pub fn walk_vis<'a, V: Visitor<'a>>(visitor: &mut V, vis: &'a Visibility) -> V::Result {
1615-
let Visibility { kind, span: _, tokens: _ } = vis;
1616-
match kind {
1617-
VisibilityKind::Restricted { path, id, shorthand: _ } => {
1618-
try_visit!(visitor.visit_path(path, *id));
1619-
}
1620-
VisibilityKind::Public | VisibilityKind::Inherited => {}
1621-
}
1622-
V::Result::output()
1623-
}
1624-
16251631
pub fn walk_attribute<'a, V: Visitor<'a>>(visitor: &mut V, attr: &'a Attribute) -> V::Result {
16261632
let Attribute { kind, id: _, style: _, span: _ } = attr;
16271633
match kind {
@@ -2698,19 +2704,6 @@ pub mod mut_visit {
26982704
}
26992705
}
27002706

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

0 commit comments

Comments
 (0)