From 6b49e774e23c04a04ff5f377fc8dae25b5c69bb0 Mon Sep 17 00:00:00 2001
From: Aleksey Kladov <aleksey.kladov@gmail.com>
Date: Sat, 11 Apr 2020 23:08:05 +0200
Subject: Remove dead code

---
 crates/ra_parser/src/grammar.rs | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

(limited to 'crates/ra_parser/src')

diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs
index d0530955e..c2a6e82e9 100644
--- a/crates/ra_parser/src/grammar.rs
+++ b/crates/ra_parser/src/grammar.rs
@@ -282,13 +282,10 @@ fn name_ref(p: &mut Parser) {
 }
 
 fn name_ref_or_index(p: &mut Parser) {
-    if p.at(IDENT) || p.at(INT_NUMBER) {
-        let m = p.start();
-        p.bump_any();
-        m.complete(p, NAME_REF);
-    } else {
-        p.err_and_bump("expected identifier");
-    }
+    assert!(p.at(IDENT) || p.at(INT_NUMBER));
+    let m = p.start();
+    p.bump_any();
+    m.complete(p, NAME_REF);
 }
 
 fn error_block(p: &mut Parser, message: &str) {
-- 
cgit v1.2.3


From 5e5eb6a108b00c573455d8d088742592012707be Mon Sep 17 00:00:00 2001
From: Aleksey Kladov <aleksey.kladov@gmail.com>
Date: Sat, 11 Apr 2020 23:33:17 +0200
Subject: Align grammar for record patterns and literals

The grammar now looks like this

   [name_ref :] pat
---
 crates/ra_parser/src/grammar/patterns.rs | 50 +++++++++++++++-----------------
 1 file changed, 23 insertions(+), 27 deletions(-)

(limited to 'crates/ra_parser/src')

diff --git a/crates/ra_parser/src/grammar/patterns.rs b/crates/ra_parser/src/grammar/patterns.rs
index 936d27575..68fb2fc73 100644
--- a/crates/ra_parser/src/grammar/patterns.rs
+++ b/crates/ra_parser/src/grammar/patterns.rs
@@ -192,14 +192,30 @@ fn record_field_pat_list(p: &mut Parser) {
         match p.current() {
             // A trailing `..` is *not* treated as a DOT_DOT_PAT.
             T![.] if p.at(T![..]) => p.bump(T![..]),
-
-            IDENT | INT_NUMBER if p.nth(1) == T![:] => record_field_pat(p),
             T!['{'] => error_block(p, "expected ident"),
-            T![box] => {
-                box_pat(p);
-            }
-            _ => {
-                bind_pat(p, false);
+
+            c => {
+                let m = p.start();
+                match c {
+                    // test record_field_pat
+                    // fn foo() {
+                    //     let S { 0: 1 } = ();
+                    //     let S { x: 1 } = ();
+                    // }
+                    IDENT | INT_NUMBER if p.nth(1) == T![:] => {
+                        name_ref_or_index(p);
+                        p.bump(T![:]);
+                        pattern(p);
+                    }
+                    T![box] => {
+                        // FIXME: not all box patterns should be allowed
+                        box_pat(p);
+                    }
+                    _ => {
+                        bind_pat(p, false);
+                    }
+                }
+                m.complete(p, RECORD_FIELD_PAT);
             }
         }
         if !p.at(T!['}']) {
@@ -210,26 +226,6 @@ fn record_field_pat_list(p: &mut Parser) {
     m.complete(p, RECORD_FIELD_PAT_LIST);
 }
 
-// test record_field_pat
-// fn foo() {
-//     let S { 0: 1 } = ();
-//     let S { x: 1 } = ();
-// }
-fn record_field_pat(p: &mut Parser) {
-    assert!(p.at(IDENT) || p.at(INT_NUMBER));
-    assert!(p.nth(1) == T![:]);
-
-    let m = p.start();
-
-    if !p.eat(INT_NUMBER) {
-        name(p)
-    }
-
-    p.bump_any();
-    pattern(p);
-    m.complete(p, RECORD_FIELD_PAT);
-}
-
 // test placeholder_pat
 // fn main() { let _ = (); }
 fn placeholder_pat(p: &mut Parser) -> CompletedMarker {
-- 
cgit v1.2.3