diff options
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar.ron | 7 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar/patterns.rs | 23 |
3 files changed, 22 insertions, 14 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 23a573d74..271040bf4 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -910,7 +910,11 @@ impl AstNode for FieldPatList { | |||
910 | 910 | ||
911 | 911 | ||
912 | impl FieldPatList { | 912 | impl FieldPatList { |
913 | pub fn pats(&self) -> impl Iterator<Item = &FieldPat> { | 913 | pub fn field_pats(&self) -> impl Iterator<Item = &FieldPat> { |
914 | super::children(self) | ||
915 | } | ||
916 | |||
917 | pub fn bind_pats(&self) -> impl Iterator<Item = &BindPat> { | ||
914 | super::children(self) | 918 | super::children(self) |
915 | } | 919 | } |
916 | } | 920 | } |
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index d8c1ae538..fc47c36d3 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron | |||
@@ -496,7 +496,12 @@ Grammar( | |||
496 | "PlaceholderPat": (), | 496 | "PlaceholderPat": (), |
497 | "PathPat": ( options: [ "Path" ] ), | 497 | "PathPat": ( options: [ "Path" ] ), |
498 | "StructPat": ( options: ["FieldPatList", "Path"] ), | 498 | "StructPat": ( options: ["FieldPatList", "Path"] ), |
499 | "FieldPatList": ( collections: [["pats", "FieldPat"]] ), | 499 | "FieldPatList": ( |
500 | collections: [ | ||
501 | ["field_pats", "FieldPat"], | ||
502 | ["bind_pats", "BindPat"], | ||
503 | ] | ||
504 | ), | ||
500 | "FieldPat": ( | 505 | "FieldPat": ( |
501 | traits: ["NameOwner"], | 506 | traits: ["NameOwner"], |
502 | options: ["Pat"] | 507 | options: ["Pat"] |
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 | ||
141 | fn field_pat(p: &mut Parser) { | 145 | fn 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 | ||