aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/grammar
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/grammar')
-rw-r--r--crates/ra_syntax/src/grammar/patterns.rs23
1 files changed, 11 insertions, 12 deletions
diff --git a/crates/ra_syntax/src/grammar/patterns.rs b/crates/ra_syntax/src/grammar/patterns.rs
index ff9d94f8a..1ac5efdf6 100644
--- a/crates/ra_syntax/src/grammar/patterns.rs
+++ b/crates/ra_syntax/src/grammar/patterns.rs
@@ -128,7 +128,11 @@ fn field_pat_list(p: &mut Parser) {
128 while !p.at(EOF) && !p.at(R_CURLY) { 128 while !p.at(EOF) && !p.at(R_CURLY) {
129 match p.current() { 129 match p.current() {
130 DOTDOT => p.bump(), 130 DOTDOT => p.bump(),
131 _ => field_pat(p), 131 IDENT if p.nth(1) == COLON => field_pat(p),
132 L_CURLY => error_block(p, "expected ident"),
133 _ => {
134 bind_pat(p, false);
135 }
132 } 136 }
133 if !p.at(R_CURLY) { 137 if !p.at(R_CURLY) {
134 p.expect(COMMA); 138 p.expect(COMMA);
@@ -139,18 +143,13 @@ fn field_pat_list(p: &mut Parser) {
139} 143}
140 144
141fn field_pat(p: &mut Parser) { 145fn field_pat(p: &mut Parser) {
146 assert!(p.at(IDENT));
147 assert!(p.nth(1) == COLON);
148
142 let m = p.start(); 149 let m = p.start();
143 match p.current() { 150 name(p);
144 IDENT if p.nth(1) == COLON => { 151 p.bump();
145 name(p); 152 pattern(p);
146 p.bump();
147 pattern(p);
148 }
149 L_CURLY => error_block(p, "expected ident"),
150 _ => {
151 bind_pat(p, false);
152 }
153 }
154 m.complete(p, FIELD_PAT); 153 m.complete(p, FIELD_PAT);
155} 154}
156 155