Skip to content

Commit 992ddeb

Browse files
committed
Unify walk_item
1 parent b5092dc commit 992ddeb

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

compiler/rustc_ast/src/visitors.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,14 @@ macro_rules! make_ast_visitor {
10671067
return_result!(V)
10681068
}
10691069

1070+
pub fn walk_item<$($lt,)? V: $trait$(<$lt>)?, I: WalkItemKind>(
1071+
visitor: &mut V,
1072+
item: ref_t!(Item<I>)
1073+
) -> result!(V) {
1074+
I::walk(item, visitor);
1075+
return_result!(V)
1076+
}
1077+
10701078
derive_copy_clone!{
10711079
#[derive(Debug)]
10721080
pub enum FnKind<'a> {
@@ -1319,14 +1327,6 @@ pub mod visit {
13191327
}
13201328
}
13211329

1322-
pub fn walk_item<'a, V: Visitor<'a>, I: WalkItemKind>(
1323-
visitor: &mut V,
1324-
item: &'a Item<I>,
1325-
) -> V::Result {
1326-
try_visit!(I::walk(item, visitor));
1327-
V::Result::output()
1328-
}
1329-
13301330
pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) -> V::Result {
13311331
let Ty { id, kind, span: _, tokens: _ } = typ;
13321332
match kind {
@@ -2427,9 +2427,6 @@ pub mod mut_visit {
24272427
visit_safety(vis, safety);
24282428
}
24292429

2430-
pub fn walk_item<K: WalkItemKind>(visitor: &mut impl MutVisitor, item: &mut Item<K>) {
2431-
K::walk(item, visitor);
2432-
}
24332430
/// Mutates one item, returning the item again.
24342431
pub fn walk_flat_map_item<K: WalkItemKind>(
24352432
visitor: &mut impl MutVisitor,

0 commit comments

Comments
 (0)