Skip to content

Commit 9dae9b6

Browse files
committed
Add flat maps to make_visit!
1 parent df3c8c2 commit 9dae9b6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

compiler/rustc_ast/src/visitors.rs

+22
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,28 @@ macro_rules! make_ast_visitor {
5959
$walk(self, node $$($$(, $arg)?)*)
6060
}
6161
};
62+
(
63+
$ty: ty
64+
$$(, $$($arg: ident)? $$(_ $ignored_arg: ident)?: $arg_ty: ty)*;
65+
$visit: ident, $walk: ident,
66+
$flat_map: ident, $walk_flat_map: ident
67+
) => {
68+
make_visit!{
69+
$ty
70+
$$(, $$($arg)? $$(_ $ignored_arg)?: $arg_ty)*;
71+
$visit, $walk
72+
}
73+
74+
macro_if!{$($mut)? {
75+
fn $flat_map(
76+
&mut self,
77+
node: $ty
78+
$$(, $$($arg)? $$($ignored_arg)?: $arg_ty)*
79+
) -> SmallVec<[$ty; 1]> {
80+
$walk_flat_map(self, node $$(, $$($arg)? $$($ignored_arg)?)*)
81+
}
82+
}}
83+
};
6284
}
6385

6486
macro_rules! P {

0 commit comments

Comments
 (0)