From e8ddeb869d43cc1b9d287236607c4ccfcd6ae221 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Thu, 18 Apr 2019 23:33:54 +0800 Subject: Fix missing last token in mbe $repeat parsing --- crates/ra_mbe/src/lib.rs | 24 ++++++++++++++++++++++++ crates/ra_mbe/src/mbe_parser.rs | 1 - 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs index 2f47e32d3..8d5008d20 100644 --- a/crates/ra_mbe/src/lib.rs +++ b/crates/ra_mbe/src/lib.rs @@ -553,6 +553,30 @@ SOURCE_FILE@[0; 40) ); } + #[test] + fn test_last_expr() { + let rules = create_rules( + r#" + macro_rules! vec { + ($($item:expr),*) => { + { + let mut v = Vec::new(); + $( + v.push($item); + )* + v + } + }; + } +"#, + ); + assert_expansion( + &rules, + "vec!(1,2,3)", + "{let mut v = Vec :: new () ; v . push (1) ; v . push (2) ; v . push (3) ; v}", + ); + } + #[test] fn test_ty() { let rules = create_rules( 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::RepeatKind::ZeroOrOne, _ => return Err(ParseError::Expected(String::from("repeat"))), }; - p.bump(); Ok(crate::Repeat { subtree, kind, separator }) } -- cgit v1.2.3