aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/grammar/patterns.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libsyntax2/src/grammar/patterns.rs')
-rw-r--r--crates/libsyntax2/src/grammar/patterns.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/libsyntax2/src/grammar/patterns.rs b/crates/libsyntax2/src/grammar/patterns.rs
index 6dd3ab2fa..29a55cb46 100644
--- a/crates/libsyntax2/src/grammar/patterns.rs
+++ b/crates/libsyntax2/src/grammar/patterns.rs
@@ -8,7 +8,11 @@ pub(super) const PATTERN_FIRST: TokenSet =
8 ]; 8 ];
9 9
10pub(super) fn pattern(p: &mut Parser) { 10pub(super) fn pattern(p: &mut Parser) {
11 if let Some(lhs) = atom_pat(p) { 11 pattern_r(p, PAT_RECOVERY_SET)
12}
13
14pub(super) fn pattern_r(p: &mut Parser, recovery_set: TokenSet) {
15 if let Some(lhs) = atom_pat(p, recovery_set) {
12 // test range_pat 16 // test range_pat
13 // fn main() { 17 // fn main() {
14 // match 92 { 0 ... 100 => () } 18 // match 92 { 0 ... 100 => () }
@@ -16,7 +20,7 @@ pub(super) fn pattern(p: &mut Parser) {
16 if p.at(DOTDOTDOT) { 20 if p.at(DOTDOTDOT) {
17 let m = lhs.precede(p); 21 let m = lhs.precede(p);
18 p.bump(); 22 p.bump();
19 atom_pat(p); 23 atom_pat(p, recovery_set);
20 m.complete(p, RANGE_PAT); 24 m.complete(p, RANGE_PAT);
21 } 25 }
22 } 26 }
@@ -26,7 +30,7 @@ const PAT_RECOVERY_SET: TokenSet =
26 token_set![LET_KW, IF_KW, WHILE_KW, LOOP_KW, MATCH_KW, R_PAREN, COMMA]; 30 token_set![LET_KW, IF_KW, WHILE_KW, LOOP_KW, MATCH_KW, R_PAREN, COMMA];
27 31
28 32
29fn atom_pat(p: &mut Parser) -> Option<CompletedMarker> { 33fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> {
30 let la0 = p.nth(0); 34 let la0 = p.nth(0);
31 let la1 = p.nth(1); 35 let la1 = p.nth(1);
32 if la0 == REF_KW || la0 == MUT_KW 36 if la0 == REF_KW || la0 == MUT_KW
@@ -56,7 +60,7 @@ fn atom_pat(p: &mut Parser) -> Option<CompletedMarker> {
56 L_PAREN => tuple_pat(p), 60 L_PAREN => tuple_pat(p),
57 L_BRACK => slice_pat(p), 61 L_BRACK => slice_pat(p),
58 _ => { 62 _ => {
59 p.err_recover("expected pattern", PAT_RECOVERY_SET); 63 p.err_recover("expected pattern", recovery_set);
60 return None; 64 return None;
61 } 65 }
62 }; 66 };