Fix missing last token in mbe $repeat parsing

This commit is contained in:
Edwin Cheng 2019-04-18 23:33:54 +08:00
parent 403cd78bae
commit e8ddeb869d
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 })
}