about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2020-07-28 20:59:48 +0200
committerAleksey Kladov <aleksey.kladov@gmail.com>2020-07-28 20:59:48 +0200
commitb10e437039c2d7e300f6be6b5de6446419a2d660 (patch)
treec08df3e0cf61f1acecdefed66b88634988dc981a
parenteb99c35b3da43020df074b91243f6b51d792d116 (diff)
downloadrust-b10e437039c2d7e300f6be6b5de6446419a2d660.tar.gz
rust-b10e437039c2d7e300f6be6b5de6446419a2d660.zip
Fix nameref parsing
-rw-r--r--crates/ra_parser/src/grammar.rs4
-rw-r--r--crates/ra_parser/src/grammar/items.rs8
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast3
3 files changed, 8 insertions, 7 deletions
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs
index caedeead082..de2c98afd9d 100644
--- a/crates/ra_parser/src/grammar.rs
+++ b/crates/ra_parser/src/grammar.rs
@@ -270,10 +270,6 @@ fn name_ref(p: &mut Parser) {
         let m = p.start();
         p.bump(IDENT);
         m.complete(p, NAME_REF);
-    } else if p.at(T![self]) {
-        let m = p.start();
-        p.bump(T![self]);
-        m.complete(p, T![self]);
     } else {
         p.err_and_bump("expected identifier");
     }
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs
index 97642bc2449..ffcdaaa9928 100644
--- a/crates/ra_parser/src/grammar/items.rs
+++ b/crates/ra_parser/src/grammar/items.rs
@@ -304,7 +304,13 @@ fn extern_crate_item(p: &mut Parser, m: Marker) {
     p.bump(T![extern]);
     assert!(p.at(T![crate]));
     p.bump(T![crate]);
-    name_ref(p);
+
+    if p.at(T![self]) {
+        p.bump(T![self]);
+    } else {
+        name_ref(p);
+    }
+
     opt_alias(p);
     p.expect(T![;]);
     m.complete(p, EXTERN_CRATE_ITEM);
diff --git a/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast b/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast
index b5bdf0aa97c..27148660504 100644
--- a/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast
@@ -28,8 +28,7 @@ SOURCE_FILE@0..69
     WHITESPACE@49..50 " "
     CRATE_KW@50..55 "crate"
     WHITESPACE@55..56 " "
-    SELF_KW@56..60
-      SELF_KW@56..60 "self"
+    SELF_KW@56..60 "self"
     WHITESPACE@60..61 " "
     ALIAS@61..67
       AS_KW@61..63 "as"