mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-14 00:47:18 +00:00
commit
8c4c5b5b80
3 changed files with 81 additions and 2 deletions
|
@ -10,7 +10,7 @@ pub(super) fn type_(p: &mut Parser) {
|
|||
UNDERSCORE => placeholder_type(p),
|
||||
FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p),
|
||||
FOR_KW => for_type(p),
|
||||
IDENT => path_type(p),
|
||||
_ if paths::is_path_start(p) => path_type(p),
|
||||
_ => {
|
||||
p.error("expected type");
|
||||
}
|
||||
|
@ -178,8 +178,13 @@ fn for_type(p: &mut Parser) {
|
|||
m.complete(p, FOR_TYPE);
|
||||
}
|
||||
|
||||
// test path_type
|
||||
// type A = Foo;
|
||||
// type B = ::Foo;
|
||||
// type C = self::Foo;
|
||||
// type D = super::Foo;
|
||||
fn path_type(p: &mut Parser) {
|
||||
assert!(p.at(IDENT));
|
||||
assert!(paths::is_path_start(p));
|
||||
let m = p.start();
|
||||
paths::type_path(p);
|
||||
m.complete(p, PATH_TYPE);
|
||||
|
|
4
tests/data/parser/inline/0032_path_type.rs
Normal file
4
tests/data/parser/inline/0032_path_type.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
type A = Foo;
|
||||
type B = ::Foo;
|
||||
type C = self::Foo;
|
||||
type D = super::Foo;
|
70
tests/data/parser/inline/0032_path_type.txt
Normal file
70
tests/data/parser/inline/0032_path_type.txt
Normal file
|
@ -0,0 +1,70 @@
|
|||
FILE@[0; 71)
|
||||
TYPE_ITEM@[0; 14)
|
||||
TYPE_KW@[0; 4)
|
||||
NAME@[4; 7)
|
||||
WHITESPACE@[4; 5)
|
||||
IDENT@[5; 6) "A"
|
||||
WHITESPACE@[6; 7)
|
||||
EQ@[7; 8)
|
||||
PATH_TYPE@[8; 12)
|
||||
PATH@[8; 12)
|
||||
PATH_SEGMENT@[8; 12)
|
||||
NAME_REF@[8; 12)
|
||||
WHITESPACE@[8; 9)
|
||||
IDENT@[9; 12) "Foo"
|
||||
SEMI@[12; 13)
|
||||
WHITESPACE@[13; 14)
|
||||
TYPE_ITEM@[14; 30)
|
||||
TYPE_KW@[14; 18)
|
||||
NAME@[18; 21)
|
||||
WHITESPACE@[18; 19)
|
||||
IDENT@[19; 20) "B"
|
||||
WHITESPACE@[20; 21)
|
||||
EQ@[21; 22)
|
||||
PATH_TYPE@[22; 28)
|
||||
PATH@[22; 28)
|
||||
PATH_SEGMENT@[22; 28)
|
||||
WHITESPACE@[22; 23)
|
||||
COLONCOLON@[23; 25)
|
||||
NAME_REF@[25; 28)
|
||||
IDENT@[25; 28) "Foo"
|
||||
SEMI@[28; 29)
|
||||
WHITESPACE@[29; 30)
|
||||
TYPE_ITEM@[30; 50)
|
||||
TYPE_KW@[30; 34)
|
||||
NAME@[34; 37)
|
||||
WHITESPACE@[34; 35)
|
||||
IDENT@[35; 36) "C"
|
||||
WHITESPACE@[36; 37)
|
||||
EQ@[37; 38)
|
||||
PATH_TYPE@[38; 48)
|
||||
PATH@[38; 48)
|
||||
PATH@[38; 43)
|
||||
PATH_SEGMENT@[38; 43)
|
||||
WHITESPACE@[38; 39)
|
||||
SELF_KW@[39; 43)
|
||||
COLONCOLON@[43; 45)
|
||||
PATH_SEGMENT@[45; 48)
|
||||
NAME_REF@[45; 48)
|
||||
IDENT@[45; 48) "Foo"
|
||||
SEMI@[48; 49)
|
||||
WHITESPACE@[49; 50)
|
||||
TYPE_ITEM@[50; 71)
|
||||
TYPE_KW@[50; 54)
|
||||
NAME@[54; 57)
|
||||
WHITESPACE@[54; 55)
|
||||
IDENT@[55; 56) "D"
|
||||
WHITESPACE@[56; 57)
|
||||
EQ@[57; 58)
|
||||
PATH_TYPE@[58; 69)
|
||||
PATH@[58; 69)
|
||||
PATH@[58; 64)
|
||||
PATH_SEGMENT@[58; 64)
|
||||
WHITESPACE@[58; 59)
|
||||
SUPER_KW@[59; 64)
|
||||
COLONCOLON@[64; 66)
|
||||
PATH_SEGMENT@[66; 69)
|
||||
NAME_REF@[66; 69)
|
||||
IDENT@[66; 69) "Foo"
|
||||
SEMI@[69; 70)
|
||||
WHITESPACE@[70; 71)
|
Loading…
Reference in a new issue