From e944fd059de93f305d6a8c40cfac5ebe84548771 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Thu, 18 Apr 2019 10:21:36 +0800 Subject: Add `item` matcher in mbe --- crates/ra_mbe/src/mbe_expander.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'crates/ra_mbe/src/mbe_expander.rs') 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 { + let item = + input.eat_item().ok_or(ExpandError::UnexpectedToken)?.clone(); + res.inner.insert(text.clone(), Binding::Simple(item.into())); + } _ => return Err(ExpandError::UnexpectedToken), } } @@ -278,6 +283,9 @@ mod tests { assert_err("($i) => ($i)", "foo!{a}", ExpandError::UnexpectedToken); assert_err("($i:) => ($i)", "foo!{a}", ExpandError::UnexpectedToken); + + // FIXME: + // Add an err test case for ($($i:ident)) => ($()) } fn assert_err(macro_body: &str, invocation: &str, err: ExpandError) { -- cgit v1.2.3