mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Merge #1164
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:
commit
d55f1136d6
2 changed files with 24 additions and 1 deletions
|
@ -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(
|
||||
|
|
|
@ -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 })
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue