mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
fix: Expand eager macros to delimited comma separated expression list
This commit is contained in:
parent
712b53865f
commit
7c765d9f9e
10 changed files with 83 additions and 6 deletions
|
@ -165,6 +165,40 @@ pub(crate) mod entry {
|
|||
}
|
||||
m.complete(p, ERROR);
|
||||
}
|
||||
|
||||
pub(crate) fn eager_macro_input(p: &mut Parser<'_>) {
|
||||
let m = p.start();
|
||||
|
||||
let closing_paren_kind = match p.current() {
|
||||
T!['{'] => T!['}'],
|
||||
T!['('] => T![')'],
|
||||
T!['['] => T![']'],
|
||||
_ => {
|
||||
p.error("expected `{`, `[`, `(`");
|
||||
while !p.at(EOF) {
|
||||
p.bump_any();
|
||||
}
|
||||
m.complete(p, ERROR);
|
||||
return;
|
||||
}
|
||||
};
|
||||
p.bump_any();
|
||||
while !p.at(EOF) && !p.at(closing_paren_kind) {
|
||||
expressions::expr(p);
|
||||
if !p.at(EOF) && !p.at(closing_paren_kind) {
|
||||
p.expect(T![,]);
|
||||
}
|
||||
}
|
||||
p.expect(closing_paren_kind);
|
||||
if p.at(EOF) {
|
||||
m.complete(p, MACRO_EAGER_INPUT);
|
||||
return;
|
||||
}
|
||||
while !p.at(EOF) {
|
||||
p.bump_any();
|
||||
}
|
||||
m.complete(p, ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue