aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/mbe_expander.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_mbe/src/mbe_expander.rs')
-rw-r--r--crates/ra_mbe/src/mbe_expander.rs19
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;
8use ra_syntax::SmolStr; 8use ra_syntax::SmolStr;
9use rustc_hash::FxHashMap; 9use rustc_hash::FxHashMap;
10 10
11use crate::tt_cursor::TtCursor;
12use crate::ExpandError; 11use crate::ExpandError;
13 12
14pub(crate) fn expand( 13pub(crate) fn expand(
@@ -19,12 +18,8 @@ pub(crate) fn expand(
19} 18}
20 19
21fn expand_rule(rule: &crate::Rule, input: &tt::Subtree) -> Result<tt::Subtree, ExpandError> { 20fn 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 }