mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 14:13:58 +00:00
fix: add err recovery for use_tree_list parsing
This commit is contained in:
parent
34df29620a
commit
e6dd522761
1 changed files with 11 additions and 10 deletions
|
@ -11,7 +11,7 @@ pub(super) fn use_(p: &mut Parser<'_>, m: Marker) {
|
||||||
|
|
||||||
// test use_tree
|
// test use_tree
|
||||||
// use outer::tree::{inner::tree};
|
// use outer::tree::{inner::tree};
|
||||||
fn use_tree(p: &mut Parser<'_>, top_level: bool) {
|
fn use_tree(p: &mut Parser<'_>, top_level: bool) -> bool {
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
match p.current() {
|
match p.current() {
|
||||||
// test use_tree_star
|
// test use_tree_star
|
||||||
|
@ -70,24 +70,25 @@ fn use_tree(p: &mut Parser<'_>, top_level: bool) {
|
||||||
// main balanced `{}`
|
// main balanced `{}`
|
||||||
p.err_and_bump(msg);
|
p.err_and_bump(msg);
|
||||||
}
|
}
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.complete(p, USE_TREE);
|
m.complete(p, USE_TREE);
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(super) const USE_TREE_LIST_RECOVERY_SET: TokenSet =
|
||||||
|
TokenSet::new(&[T![;], T![,], T![.], T![ident]]);
|
||||||
|
|
||||||
// test use_tree_list
|
// test use_tree_list
|
||||||
// use {a, b, c};
|
// use {a, b, c};
|
||||||
pub(crate) fn use_tree_list(p: &mut Parser<'_>) {
|
pub(crate) fn use_tree_list(p: &mut Parser<'_>) {
|
||||||
assert!(p.at(T!['{']));
|
assert!(p.at(T!['{']));
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
p.bump(T!['{']);
|
|
||||||
while !p.at(EOF) && !p.at(T!['}']) {
|
delimited(p, T!['{'], T!['}'], T![,], USE_TREE_LIST_RECOVERY_SET, |p: &mut Parser<'_>| {
|
||||||
use_tree(p, false);
|
use_tree(p, false) || p.at_ts(USE_TREE_LIST_RECOVERY_SET)
|
||||||
if !p.at(T!['}']) {
|
});
|
||||||
p.expect(T![,]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p.expect(T!['}']);
|
|
||||||
m.complete(p, USE_TREE_LIST);
|
m.complete(p, USE_TREE_LIST);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue