File tree 2 files changed +44
-0
lines changed
2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 15
15
#![ feature( box_patterns) ]
16
16
#![ feature( if_let_guard) ]
17
17
#![ feature( let_chains) ]
18
+ #![ feature( macro_metavar_expr) ]
18
19
#![ feature( negative_impls) ]
19
20
#![ feature( never_type) ]
20
21
#![ feature( rustdoc_internals) ]
Original file line number Diff line number Diff line change @@ -26,6 +26,49 @@ macro_rules! macro_if {
26
26
27
27
macro_rules! make_ast_visitor {
28
28
( $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
+
29
72
/// Each method of the traits `Visitor` and `MutVisitor` trait is a hook
30
73
/// to be potentially overridden. Each method's default implementation
31
74
/// recursively visits the substructure of the input via the corresponding
You can’t perform that action at this time.
0 commit comments