diff options
author | Edwin Cheng <[email protected]> | 2019-04-18 03:21:36 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-04-18 03:21:36 +0100 |
commit | e944fd059de93f305d6a8c40cfac5ebe84548771 (patch) | |
tree | 9e7ff9215e3490169c63c12e03c2eb03ca59ba20 /crates/ra_mbe/src/mbe_expander.rs | |
parent | 112fd0ec7d65b5f23865410fd3e188e761d97110 (diff) |
Add `item` matcher in mbe
Diffstat (limited to 'crates/ra_mbe/src/mbe_expander.rs')
-rw-r--r-- | crates/ra_mbe/src/mbe_expander.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs index 7587b575d..acba42809 100644 --- a/crates/ra_mbe/src/mbe_expander.rs +++ b/crates/ra_mbe/src/mbe_expander.rs | |||
@@ -161,6 +161,11 @@ fn match_lhs(pattern: &crate::Subtree, input: &mut TtCursor) -> Result<Bindings, | |||
161 | let pat = input.eat_stmt().ok_or(ExpandError::UnexpectedToken)?.clone(); | 161 | let pat = input.eat_stmt().ok_or(ExpandError::UnexpectedToken)?.clone(); |
162 | res.inner.insert(text.clone(), Binding::Simple(pat.into())); | 162 | res.inner.insert(text.clone(), Binding::Simple(pat.into())); |
163 | } | 163 | } |
164 | "item" => { | ||
165 | let item = | ||
166 | input.eat_item().ok_or(ExpandError::UnexpectedToken)?.clone(); | ||
167 | res.inner.insert(text.clone(), Binding::Simple(item.into())); | ||
168 | } | ||
164 | _ => return Err(ExpandError::UnexpectedToken), | 169 | _ => return Err(ExpandError::UnexpectedToken), |
165 | } | 170 | } |
166 | } | 171 | } |
@@ -278,6 +283,9 @@ mod tests { | |||
278 | 283 | ||
279 | assert_err("($i) => ($i)", "foo!{a}", ExpandError::UnexpectedToken); | 284 | assert_err("($i) => ($i)", "foo!{a}", ExpandError::UnexpectedToken); |
280 | assert_err("($i:) => ($i)", "foo!{a}", ExpandError::UnexpectedToken); | 285 | assert_err("($i:) => ($i)", "foo!{a}", ExpandError::UnexpectedToken); |
286 | |||
287 | // FIXME: | ||
288 | // Add an err test case for ($($i:ident)) => ($()) | ||
281 | } | 289 | } |
282 | 290 | ||
283 | fn assert_err(macro_body: &str, invocation: &str, err: ExpandError) { | 291 | fn assert_err(macro_body: &str, invocation: &str, err: ExpandError) { |