Skip to content

Commit 7048243

Browse files
committed
Unify WalkItemKind
1 parent c7b5536 commit 7048243

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

compiler/rustc_ast/src/visitors.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,13 @@ macro_rules! make_ast_visitor {
11671167
}
11681168
}
11691169

1170+
pub trait WalkItemKind: Sized {
1171+
fn walk<$($lt,)? V: $trait$(<$lt>)?>(
1172+
item: ref_t!(Item<Self>),
1173+
visitor: &mut V,
1174+
) -> result!(V);
1175+
}
1176+
11701177
make_walk_flat_map!{Arm, walk_flat_map_arm, visit_arm}
11711178
make_walk_flat_map!{Attribute, walk_flat_map_attribute, visit_attribute}
11721179
make_walk_flat_map!{ExprField, walk_flat_map_expr_field, visit_expr_field}
@@ -1286,13 +1293,6 @@ pub mod visit {
12861293
GenericArg,
12871294
}
12881295

1289-
pub trait WalkItemKind: Sized {
1290-
fn walk<'a, V: Visitor<'a>>(
1291-
item: &'a Item<Self>,
1292-
visitor: &mut V,
1293-
) -> V::Result;
1294-
}
1295-
12961296
make_ast_visitor!(Visitor<'ast>);
12971297

12981298
impl WalkItemKind for ItemKind {
@@ -1840,10 +1840,6 @@ pub mod mut_visit {
18401840
}
18411841
}
18421842

1843-
pub trait WalkItemKind: Sized {
1844-
fn walk(item: &mut Item<Self>, visitor: &mut impl MutVisitor);
1845-
}
1846-
18471843
make_ast_visitor!(MutVisitor, mut);
18481844

18491845
/// Use a map-style function (`FnOnce(T) -> T`) to overwrite a `&mut T`. Useful
@@ -2257,7 +2253,7 @@ pub mod mut_visit {
22572253
}
22582254

22592255
impl WalkItemKind for ItemKind {
2260-
fn walk(item: &mut Item<Self>, visitor: &mut impl MutVisitor) {
2256+
fn walk<V: MutVisitor>(item: &mut Item<Self>, visitor: &mut V) {
22612257
let Item { attrs, id, span, vis, ident, kind, tokens } = item;
22622258
visitor.visit_id(id);
22632259
visit_attrs(visitor, attrs);
@@ -2498,7 +2494,7 @@ pub mod mut_visit {
24982494

24992495

25002496
impl WalkItemKind for ForeignItemKind {
2501-
fn walk(item: &mut Item<Self>, visitor: &mut impl MutVisitor) {
2497+
fn walk<V: MutVisitor>(item: &mut Item<Self>, visitor: &mut V) {
25022498
let Item { attrs, id, span, vis, ident, kind, tokens } = item;
25032499
visitor.visit_id(id);
25042500
visit_attrs(visitor, attrs);

0 commit comments

Comments
 (0)