1164: Fix missing last token in mbe $repeat parsing r=matklad a=edwin0cheng

The `mbe parser` incorrectly eat one more token in $repeat parsing, described in #1141.

Remove incorrect token eating, and add related test.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
This commit is contained in:
bors[bot] 2019-04-18 18:13:09 +00:00
commit d55f1136d6
2 changed files with 24 additions and 1 deletions

View file

@ -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(

View file

@ -91,7 +91,6 @@ fn parse_repeat(p: &mut TtCursor) -> Result<crate::Repeat, ParseError> {
'?' => crate::RepeatKind::ZeroOrOne,
_ => return Err(ParseError::Expected(String::from("repeat"))),
};
p.bump();
Ok(crate::Repeat { subtree, kind, separator })
}