mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
support 2018 paths
This commit is contained in:
parent
5e1d109cbb
commit
baaf027da0
3 changed files with 21 additions and 3 deletions
|
@ -1,11 +1,11 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
pub(super) const PATH_FIRST: TokenSet =
|
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 {
|
pub(super) fn is_path_start(p: &Parser) -> bool {
|
||||||
match p.current() {
|
match p.current() {
|
||||||
IDENT | SELF_KW | SUPER_KW | COLONCOLON => true,
|
IDENT | SELF_KW | SUPER_KW | CRATE_KW | COLONCOLON => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,9 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
|
||||||
name_ref(p);
|
name_ref(p);
|
||||||
opt_path_type_args(p, mode);
|
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");
|
p.err_and_bump("expected identifier");
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
use crate::foo;
|
|
@ -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)
|
Loading…
Reference in a new issue