diff options
Diffstat (limited to 'crates/ra_mbe/src')
-rw-r--r-- | crates/ra_mbe/src/lib.rs | 22 | ||||
-rw-r--r-- | crates/ra_mbe/src/mbe_expander.rs | 2 |
2 files changed, 12 insertions, 12 deletions
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs index b09837831..b9f555ef6 100644 --- a/crates/ra_mbe/src/lib.rs +++ b/crates/ra_mbe/src/lib.rs | |||
@@ -26,11 +26,11 @@ pub use tt::{Delimiter, Punct}; | |||
26 | 26 | ||
27 | pub use crate::syntax_bridge::ast_to_token_tree; | 27 | pub use crate::syntax_bridge::ast_to_token_tree; |
28 | 28 | ||
29 | /// This struct contains AST for a single `macro_rules` defenition. What might | 29 | /// This struct contains AST for a single `macro_rules` definition. What might |
30 | /// be very confusing is that AST has almost exactly the same shape as | 30 | /// be very confusing is that AST has almost exactly the same shape as |
31 | /// `tt::TokenTree`, but there's a crucial difference: in macro rules, `$ident` | 31 | /// `tt::TokenTree`, but there's a crucial difference: in macro rules, `$ident` |
32 | /// and `$()*` have special meaning (see `Var` and `Repeat` data structures) | 32 | /// and `$()*` have special meaning (see `Var` and `Repeat` data structures) |
33 | #[derive(Debug)] | 33 | #[derive(Debug, PartialEq, Eq)] |
34 | pub struct MacroRules { | 34 | pub struct MacroRules { |
35 | pub(crate) rules: Vec<Rule>, | 35 | pub(crate) rules: Vec<Rule>, |
36 | } | 36 | } |
@@ -44,13 +44,13 @@ impl MacroRules { | |||
44 | } | 44 | } |
45 | } | 45 | } |
46 | 46 | ||
47 | #[derive(Debug)] | 47 | #[derive(Debug, PartialEq, Eq)] |
48 | pub(crate) struct Rule { | 48 | pub(crate) struct Rule { |
49 | pub(crate) lhs: Subtree, | 49 | pub(crate) lhs: Subtree, |
50 | pub(crate) rhs: Subtree, | 50 | pub(crate) rhs: Subtree, |
51 | } | 51 | } |
52 | 52 | ||
53 | #[derive(Debug)] | 53 | #[derive(Debug, PartialEq, Eq)] |
54 | pub(crate) enum TokenTree { | 54 | pub(crate) enum TokenTree { |
55 | Leaf(Leaf), | 55 | Leaf(Leaf), |
56 | Subtree(Subtree), | 56 | Subtree(Subtree), |
@@ -58,7 +58,7 @@ pub(crate) enum TokenTree { | |||
58 | } | 58 | } |
59 | impl_froms!(TokenTree: Leaf, Subtree, Repeat); | 59 | impl_froms!(TokenTree: Leaf, Subtree, Repeat); |
60 | 60 | ||
61 | #[derive(Debug)] | 61 | #[derive(Debug, PartialEq, Eq)] |
62 | pub(crate) enum Leaf { | 62 | pub(crate) enum Leaf { |
63 | Literal(Literal), | 63 | Literal(Literal), |
64 | Punct(Punct), | 64 | Punct(Punct), |
@@ -67,37 +67,37 @@ pub(crate) enum Leaf { | |||
67 | } | 67 | } |
68 | impl_froms!(Leaf: Literal, Punct, Ident, Var); | 68 | impl_froms!(Leaf: Literal, Punct, Ident, Var); |
69 | 69 | ||
70 | #[derive(Debug)] | 70 | #[derive(Debug, PartialEq, Eq)] |
71 | pub(crate) struct Subtree { | 71 | pub(crate) struct Subtree { |
72 | pub(crate) delimiter: Delimiter, | 72 | pub(crate) delimiter: Delimiter, |
73 | pub(crate) token_trees: Vec<TokenTree>, | 73 | pub(crate) token_trees: Vec<TokenTree>, |
74 | } | 74 | } |
75 | 75 | ||
76 | #[derive(Debug)] | 76 | #[derive(Debug, PartialEq, Eq)] |
77 | pub(crate) struct Repeat { | 77 | pub(crate) struct Repeat { |
78 | pub(crate) subtree: Subtree, | 78 | pub(crate) subtree: Subtree, |
79 | pub(crate) kind: RepeatKind, | 79 | pub(crate) kind: RepeatKind, |
80 | pub(crate) separator: Option<char>, | 80 | pub(crate) separator: Option<char>, |
81 | } | 81 | } |
82 | 82 | ||
83 | #[derive(Debug)] | 83 | #[derive(Debug, PartialEq, Eq)] |
84 | pub(crate) enum RepeatKind { | 84 | pub(crate) enum RepeatKind { |
85 | ZeroOrMore, | 85 | ZeroOrMore, |
86 | OneOrMore, | 86 | OneOrMore, |
87 | ZeroOrOne, | 87 | ZeroOrOne, |
88 | } | 88 | } |
89 | 89 | ||
90 | #[derive(Debug)] | 90 | #[derive(Debug, PartialEq, Eq)] |
91 | pub(crate) struct Literal { | 91 | pub(crate) struct Literal { |
92 | pub(crate) text: SmolStr, | 92 | pub(crate) text: SmolStr, |
93 | } | 93 | } |
94 | 94 | ||
95 | #[derive(Debug)] | 95 | #[derive(Debug, PartialEq, Eq)] |
96 | pub(crate) struct Ident { | 96 | pub(crate) struct Ident { |
97 | pub(crate) text: SmolStr, | 97 | pub(crate) text: SmolStr, |
98 | } | 98 | } |
99 | 99 | ||
100 | #[derive(Debug)] | 100 | #[derive(Debug, PartialEq, Eq)] |
101 | pub(crate) struct Var { | 101 | pub(crate) struct Var { |
102 | pub(crate) text: SmolStr, | 102 | pub(crate) text: SmolStr, |
103 | pub(crate) kind: Option<SmolStr>, | 103 | pub(crate) kind: Option<SmolStr>, |
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs index 31531f4c9..eec713d9c 100644 --- a/crates/ra_mbe/src/mbe_expander.rs +++ b/crates/ra_mbe/src/mbe_expander.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | /// This module takes a (parsed) defenition of `macro_rules` invocation, a | 1 | /// This module takes a (parsed) definition of `macro_rules` invocation, a |
2 | /// `tt::TokenTree` representing an argument of macro invocation, and produces a | 2 | /// `tt::TokenTree` representing an argument of macro invocation, and produces a |
3 | /// `tt::TokenTree` for the result of the expansion. | 3 | /// `tt::TokenTree` for the result of the expansion. |
4 | use rustc_hash::FxHashMap; | 4 | use rustc_hash::FxHashMap; |