mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Improve readability of the parser code
This commit is contained in:
parent
00a0125372
commit
2a41b2cd94
10 changed files with 38 additions and 63 deletions
|
@ -255,9 +255,7 @@ fn is_literal_pat_start(p: &Parser<'_>) -> bool {
|
|||
fn literal_pat(p: &mut Parser<'_>) -> CompletedMarker {
|
||||
assert!(is_literal_pat_start(p));
|
||||
let m = p.start();
|
||||
if p.at(T![-]) {
|
||||
p.bump(T![-]);
|
||||
}
|
||||
p.eat(T![-]);
|
||||
expressions::literal(p);
|
||||
m.complete(p, LITERAL_PAT)
|
||||
}
|
||||
|
@ -468,14 +466,12 @@ fn slice_pat(p: &mut Parser<'_>) -> CompletedMarker {
|
|||
fn pat_list(p: &mut Parser<'_>, ket: SyntaxKind) {
|
||||
while !p.at(EOF) && !p.at(ket) {
|
||||
pattern_top(p);
|
||||
if !p.at(T![,]) {
|
||||
if !p.eat(T![,]) {
|
||||
if p.at_ts(PAT_TOP_FIRST) {
|
||||
p.error(format!("expected {:?}, got {:?}", T![,], p.current()));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
p.bump(T![,]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue