diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_mbe/src/lib.rs | 24 | ||||
-rw-r--r-- | crates/ra_mbe/src/mbe_parser.rs | 1 |
2 files changed, 24 insertions, 1 deletions
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs index 3a9db7835..9d4744838 100644 --- a/crates/ra_mbe/src/lib.rs +++ b/crates/ra_mbe/src/lib.rs | |||
@@ -620,6 +620,30 @@ MACRO_ITEMS@[0; 40) | |||
620 | } | 620 | } |
621 | 621 | ||
622 | #[test] | 622 | #[test] |
623 | fn test_last_expr() { | ||
624 | let rules = create_rules( | ||
625 | r#" | ||
626 | macro_rules! vec { | ||
627 | ($($item:expr),*) => { | ||
628 | { | ||
629 | let mut v = Vec::new(); | ||
630 | $( | ||
631 | v.push($item); | ||
632 | )* | ||
633 | v | ||
634 | } | ||
635 | }; | ||
636 | } | ||
637 | "#, | ||
638 | ); | ||
639 | assert_expansion( | ||
640 | &rules, | ||
641 | "vec!(1,2,3)", | ||
642 | "{let mut v = Vec :: new () ; v . push (1) ; v . push (2) ; v . push (3) ; v}", | ||
643 | ); | ||
644 | } | ||
645 | |||
646 | #[test] | ||
623 | fn test_ty() { | 647 | fn test_ty() { |
624 | let rules = create_rules( | 648 | let rules = create_rules( |
625 | r#" | 649 | r#" |
diff --git a/crates/ra_mbe/src/mbe_parser.rs b/crates/ra_mbe/src/mbe_parser.rs index e3669f66c..f37c422d3 100644 --- a/crates/ra_mbe/src/mbe_parser.rs +++ b/crates/ra_mbe/src/mbe_parser.rs | |||
@@ -91,7 +91,6 @@ fn parse_repeat(p: &mut TtCursor) -> Result<crate::Repeat, ParseError> { | |||
91 | '?' => crate::RepeatKind::ZeroOrOne, | 91 | '?' => crate::RepeatKind::ZeroOrOne, |
92 | _ => return Err(ParseError::Expected(String::from("repeat"))), | 92 | _ => return Err(ParseError::Expected(String::from("repeat"))), |
93 | }; | 93 | }; |
94 | p.bump(); | ||
95 | Ok(crate::Repeat { subtree, kind, separator }) | 94 | Ok(crate::Repeat { subtree, kind, separator }) |
96 | } | 95 | } |
97 | 96 | ||