File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1515#![ feature( box_patterns) ]
1616#![ feature( if_let_guard) ]
1717#![ feature( let_chains) ]
18+ #![ feature( macro_metavar_expr) ]
1819#![ feature( negative_impls) ]
1920#![ feature( never_type) ]
2021#![ feature( rustdoc_internals) ]
Original file line number Diff line number Diff line change @@ -26,6 +26,49 @@ macro_rules! macro_if {
2626
2727macro_rules! make_ast_visitor {
2828 ( $trait: ident $( <$lt: lifetime>) ? $( , $mut: ident) ?) => {
29+ #[ allow( unused) ]
30+ macro_rules! ref_t {
31+ ( $t: ty) => { & $( $lt) ? $( $mut) ? $t } ;
32+ }
33+
34+ #[ allow( unused) ]
35+ macro_rules! result {
36+ ( $V: ty) => {
37+ macro_if!( $( $mut) ? { ( ) } else { <$V>:: Result } )
38+ } ;
39+ ( ) => {
40+ result!( Self )
41+ } ;
42+ }
43+
44+ #[ allow( unused) ]
45+ macro_rules! make_visit {
46+ (
47+ $ty: ty
48+ $$( , $$( $arg: ident) ? $$( _ $ignored_arg: ident) ?: $arg_ty: ty) * ;
49+ $visit: ident, $walk: ident
50+ ) => {
51+ fn $visit(
52+ & mut self ,
53+ node: ref_t!( $ty)
54+ $$( , $$( $arg) ? $$( #[ allow( unused) ] $ignored_arg) ?: $arg_ty) *
55+ ) -> result!( ) {
56+ $walk( self , node $$( $$( , $arg) ?) * )
57+ }
58+ } ;
59+ }
60+
61+ #[ allow( unused) ]
62+ macro_rules! P {
63+ ( $t: ty) => {
64+ macro_if!{ $( $mut) ? {
65+ P <$t>
66+ } else {
67+ $t
68+ } }
69+ } ;
70+ }
71+
2972 /// Each method of the traits `Visitor` and `MutVisitor` trait is a hook
3073 /// to be potentially overridden. Each method's default implementation
3174 /// recursively visits the substructure of the input via the corresponding
You can’t perform that action at this time.
0 commit comments