aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-09-29 12:53:23 +0100
committerAleksey Kladov <[email protected]>2018-09-29 12:53:23 +0100
commitbaaf027da04445c18e6d50b0956b234d33c1a2f1 (patch)
treec87835c5733b269c7bb2ed101dab00151f1fedd3 /crates/ra_syntax
parent5e1d109cbb73a66c8bd3282973b8ebeb74894e4e (diff)
support 2018 paths
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/grammar/paths.rs8
-rw-r--r--crates/ra_syntax/tests/data/parser/inline/0112_crate_path.rs1
-rw-r--r--crates/ra_syntax/tests/data/parser/inline/0112_crate_path.txt15
3 files changed, 21 insertions, 3 deletions
diff --git a/crates/ra_syntax/src/grammar/paths.rs b/crates/ra_syntax/src/grammar/paths.rs
index 7c9fb8be2..b6d44d53a 100644
--- a/crates/ra_syntax/src/grammar/paths.rs
+++ b/crates/ra_syntax/src/grammar/paths.rs
@@ -1,11 +1,11 @@
1use super::*; 1use super::*;
2 2
3pub(super) const PATH_FIRST: TokenSet = 3pub(super) const PATH_FIRST: TokenSet =
4 token_set![IDENT, SELF_KW, SUPER_KW, COLONCOLON, L_ANGLE]; 4 token_set![IDENT, SELF_KW, SUPER_KW, CRATE_KW, COLONCOLON, L_ANGLE];
5 5
6pub(super) fn is_path_start(p: &Parser) -> bool { 6pub(super) fn is_path_start(p: &Parser) -> bool {
7 match p.current() { 7 match p.current() {
8 IDENT | SELF_KW | SUPER_KW | COLONCOLON => true, 8 IDENT | SELF_KW | SUPER_KW | CRATE_KW | COLONCOLON => true,
9 _ => false, 9 _ => false,
10 } 10 }
11} 11}
@@ -74,7 +74,9 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
74 name_ref(p); 74 name_ref(p);
75 opt_path_type_args(p, mode); 75 opt_path_type_args(p, mode);
76 } 76 }
77 SELF_KW | SUPER_KW => p.bump(), 77 // test crate_path
78 // use crate::foo;
79 SELF_KW | SUPER_KW | CRATE_KW => p.bump(),
78 _ => { 80 _ => {
79 p.err_and_bump("expected identifier"); 81 p.err_and_bump("expected identifier");
80 } 82 }
diff --git a/crates/ra_syntax/tests/data/parser/inline/0112_crate_path.rs b/crates/ra_syntax/tests/data/parser/inline/0112_crate_path.rs
new file mode 100644
index 000000000..1bbb5930b
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/inline/0112_crate_path.rs
@@ -0,0 +1 @@
use crate::foo;
diff --git a/crates/ra_syntax/tests/data/parser/inline/0112_crate_path.txt b/crates/ra_syntax/tests/data/parser/inline/0112_crate_path.txt
new file mode 100644
index 000000000..4c871ccdd
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/inline/0112_crate_path.txt
@@ -0,0 +1,15 @@
1ROOT@[0; 16)
2 USE_ITEM@[0; 15)
3 USE_KW@[0; 3)
4 WHITESPACE@[3; 4)
5 USE_TREE@[4; 14)
6 PATH@[4; 14)
7 PATH@[4; 9)
8 PATH_SEGMENT@[4; 9)
9 CRATE_KW@[4; 9)
10 COLONCOLON@[9; 11)
11 PATH_SEGMENT@[11; 14)
12 NAME_REF@[11; 14)
13 IDENT@[11; 14) "foo"
14 SEMI@[14; 15)
15 WHITESPACE@[15; 16)