aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/grammar/patterns.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/grammar/patterns.rs')
-rw-r--r--crates/ra_syntax/src/grammar/patterns.rs26
1 files changed, 17 insertions, 9 deletions
diff --git a/crates/ra_syntax/src/grammar/patterns.rs b/crates/ra_syntax/src/grammar/patterns.rs
index 7820c4e02..ff9d94f8a 100644
--- a/crates/ra_syntax/src/grammar/patterns.rs
+++ b/crates/ra_syntax/src/grammar/patterns.rs
@@ -128,15 +128,7 @@ 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 IDENT if p.nth(1) == COLON => { 131 _ => field_pat(p),
132 p.bump();
133 p.bump();
134 pattern(p);
135 }
136 L_CURLY => error_block(p, "expected ident"),
137 _ => {
138 bind_pat(p, false);
139 }
140 } 132 }
141 if !p.at(R_CURLY) { 133 if !p.at(R_CURLY) {
142 p.expect(COMMA); 134 p.expect(COMMA);
@@ -146,6 +138,22 @@ fn field_pat_list(p: &mut Parser) {
146 m.complete(p, FIELD_PAT_LIST); 138 m.complete(p, FIELD_PAT_LIST);
147} 139}
148 140
141fn field_pat(p: &mut Parser) {
142 let m = p.start();
143 match p.current() {
144 IDENT if p.nth(1) == COLON => {
145 name(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);
155}
156
149// test placeholder_pat 157// test placeholder_pat
150// fn main() { let _ = (); } 158// fn main() { let _ = (); }
151fn placeholder_pat(p: &mut Parser) -> CompletedMarker { 159fn placeholder_pat(p: &mut Parser) -> CompletedMarker {