Skip to content

Commit 2a77019

Browse files
Merge #1070
1070: Support extern_crate_self r=matklad a=memoryruins closes #1069 Co-authored-by: memoryruins <[email protected]>
2 parents de56dba + 7a06282 commit 2a77019

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

crates/ra_parser/src/grammar.rs

+4
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ fn name_ref(p: &mut Parser) {
184184
let m = p.start();
185185
p.bump();
186186
m.complete(p, NAME_REF);
187+
} else if p.at(SELF_KW) {
188+
let m = p.start();
189+
p.bump();
190+
m.complete(p, SELF_KW);
187191
} else {
188192
p.err_and_bump("expected identifier");
189193
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
extern crate foo;
22
extern crate foo as bar;
3+
extern crate self as baz;

crates/ra_syntax/tests/data/parser/ok/0007_extern_crate.txt

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SOURCE_FILE@[0; 43)
1+
SOURCE_FILE@[0; 69)
22
EXTERN_CRATE_ITEM@[0; 17)
33
EXTERN_KW@[0; 6)
44
WHITESPACE@[6; 7)
@@ -23,3 +23,18 @@ SOURCE_FILE@[0; 43)
2323
IDENT@[38; 41) "bar"
2424
SEMI@[41; 42)
2525
WHITESPACE@[42; 43)
26+
EXTERN_CRATE_ITEM@[43; 68)
27+
EXTERN_KW@[43; 49)
28+
WHITESPACE@[49; 50)
29+
CRATE_KW@[50; 55)
30+
WHITESPACE@[55; 56)
31+
SELF_KW@[56; 60)
32+
SELF_KW@[56; 60)
33+
WHITESPACE@[60; 61)
34+
ALIAS@[61; 67)
35+
AS_KW@[61; 63)
36+
WHITESPACE@[63; 64)
37+
NAME@[64; 67)
38+
IDENT@[64; 67) "baz"
39+
SEMI@[67; 68)
40+
WHITESPACE@[68; 69)

0 commit comments

Comments
 (0)