diff options
Diffstat (limited to 'crates/ra_mbe/src/mbe_expander.rs')
-rw-r--r-- | crates/ra_mbe/src/mbe_expander.rs | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs index 15d9d83e2..b455b7321 100644 --- a/crates/ra_mbe/src/mbe_expander.rs +++ b/crates/ra_mbe/src/mbe_expander.rs | |||
@@ -8,7 +8,6 @@ mod transcriber; | |||
8 | use ra_syntax::SmolStr; | 8 | use ra_syntax::SmolStr; |
9 | use rustc_hash::FxHashMap; | 9 | use rustc_hash::FxHashMap; |
10 | 10 | ||
11 | use crate::tt_cursor::TtCursor; | ||
12 | use crate::ExpandError; | 11 | use crate::ExpandError; |
13 | 12 | ||
14 | pub(crate) fn expand( | 13 | pub(crate) fn expand( |
@@ -19,12 +18,8 @@ pub(crate) fn expand( | |||
19 | } | 18 | } |
20 | 19 | ||
21 | fn expand_rule(rule: &crate::Rule, input: &tt::Subtree) -> Result<tt::Subtree, ExpandError> { | 20 | fn expand_rule(rule: &crate::Rule, input: &tt::Subtree) -> Result<tt::Subtree, ExpandError> { |
22 | let mut input = TtCursor::new(input); | 21 | let bindings = matcher::match_(&rule.lhs, input)?; |
23 | let bindings = matcher::match_lhs(&rule.lhs, &mut input)?; | 22 | let res = transcriber::transcribe(&rule.rhs, &bindings)?; |
24 | if !input.is_eof() { | ||
25 | return Err(ExpandError::UnexpectedToken); | ||
26 | } | ||
27 | let res = transcriber::transcribe(&bindings, &rule.rhs)?; | ||
28 | Ok(res) | 23 | Ok(res) |
29 | } | 24 | } |
30 | 25 | ||
@@ -103,13 +98,6 @@ mod tests { | |||
103 | 98 | ||
104 | #[test] | 99 | #[test] |
105 | fn test_expand_rule() { | 100 | fn test_expand_rule() { |
106 | // FIXME: The missing $var check should be in parsing phase | ||
107 | // assert_err( | ||
108 | // "($i:ident) => ($j)", | ||
109 | // "foo!{a}", | ||
110 | // ExpandError::BindingError(String::from("could not find binding `j`")), | ||
111 | // ); | ||
112 | |||
113 | assert_err( | 101 | assert_err( |
114 | "($($i:ident);*) => ($i)", | 102 | "($($i:ident);*) => ($i)", |
115 | "foo!{a}", | 103 | "foo!{a}", |
@@ -118,9 +106,6 @@ mod tests { | |||
118 | )), | 106 | )), |
119 | ); | 107 | ); |
120 | 108 | ||
121 | assert_err("($i) => ($i)", "foo!{a}", ExpandError::UnexpectedToken); | ||
122 | assert_err("($i:) => ($i)", "foo!{a}", ExpandError::UnexpectedToken); | ||
123 | |||
124 | // FIXME: | 109 | // FIXME: |
125 | // Add an err test case for ($($i:ident)) => ($()) | 110 | // Add an err test case for ($($i:ident)) => ($()) |
126 | } | 111 | } |