diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-18 13:00:16 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-18 13:00:16 +0100 |
commit | 403cd78baee7e9c2410d04ca0304575e7bbab16d (patch) | |
tree | 9e7ff9215e3490169c63c12e03c2eb03ca59ba20 /crates/ra_mbe/src/mbe_expander.rs | |
parent | 112fd0ec7d65b5f23865410fd3e188e761d97110 (diff) | |
parent | e944fd059de93f305d6a8c40cfac5ebe84548771 (diff) |
Merge #1161
1161: Add mbe 'item' matcher r=matklad a=edwin0cheng
Add `item` matcher in `ra_mbe` , and added corresponding `item()` parser in `ra_syntax`.
This PR also help PR #1148 for `Items` parsing.
And hopefully fix #1149 ?!
Co-authored-by: Edwin Cheng <[email protected]>
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) { |