aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-04-18 16:33:54 +0100
committerEdwin Cheng <[email protected]>2019-04-18 16:33:54 +0100
commite8ddeb869d43cc1b9d287236607c4ccfcd6ae221 (patch)
tree245ce2d29a73aa091a80d055498a4458a68e9851
parent403cd78baee7e9c2410d04ca0304575e7bbab16d (diff)
Fix missing last token in mbe $repeat parsing
-rw-r--r--crates/ra_mbe/src/lib.rs24
-rw-r--r--crates/ra_mbe/src/mbe_parser.rs1
2 files changed, 24 insertions, 1 deletions
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
@@ -554,6 +554,30 @@ SOURCE_FILE@[0; 40)
554 } 554 }
555 555
556 #[test] 556 #[test]
557 fn test_last_expr() {
558 let rules = create_rules(
559 r#"
560 macro_rules! vec {
561 ($($item:expr),*) => {
562 {
563 let mut v = Vec::new();
564 $(
565 v.push($item);
566 )*
567 v
568 }
569 };
570 }
571"#,
572 );
573 assert_expansion(
574 &rules,
575 "vec!(1,2,3)",
576 "{let mut v = Vec :: new () ; v . push (1) ; v . push (2) ; v . push (3) ; v}",
577 );
578 }
579
580 #[test]
557 fn test_ty() { 581 fn test_ty() {
558 let rules = create_rules( 582 let rules = create_rules(
559 r#" 583 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