From baaf027da04445c18e6d50b0956b234d33c1a2f1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 29 Sep 2018 14:53:23 +0300 Subject: support 2018 paths --- crates/ra_syntax/src/grammar/paths.rs | 8 +++++--- .../ra_syntax/tests/data/parser/inline/0112_crate_path.rs | 1 + .../tests/data/parser/inline/0112_crate_path.txt | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 crates/ra_syntax/tests/data/parser/inline/0112_crate_path.rs create mode 100644 crates/ra_syntax/tests/data/parser/inline/0112_crate_path.txt 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 @@ use super::*; pub(super) const PATH_FIRST: TokenSet = - token_set![IDENT, SELF_KW, SUPER_KW, COLONCOLON, L_ANGLE]; + token_set![IDENT, SELF_KW, SUPER_KW, CRATE_KW, COLONCOLON, L_ANGLE]; pub(super) fn is_path_start(p: &Parser) -> bool { match p.current() { - IDENT | SELF_KW | SUPER_KW | COLONCOLON => true, + IDENT | SELF_KW | SUPER_KW | CRATE_KW | COLONCOLON => true, _ => false, } } @@ -74,7 +74,9 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) { name_ref(p); opt_path_type_args(p, mode); } - SELF_KW | SUPER_KW => p.bump(), + // test crate_path + // use crate::foo; + SELF_KW | SUPER_KW | CRATE_KW => p.bump(), _ => { p.err_and_bump("expected identifier"); } 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 @@ +ROOT@[0; 16) + USE_ITEM@[0; 15) + USE_KW@[0; 3) + WHITESPACE@[3; 4) + USE_TREE@[4; 14) + PATH@[4; 14) + PATH@[4; 9) + PATH_SEGMENT@[4; 9) + CRATE_KW@[4; 9) + COLONCOLON@[9; 11) + PATH_SEGMENT@[11; 14) + NAME_REF@[11; 14) + IDENT@[11; 14) "foo" + SEMI@[14; 15) + WHITESPACE@[15; 16) -- cgit v1.2.3