mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 21:28:51 +00:00
G: placeholder types
This commit is contained in:
parent
eb4c05d572
commit
2fb33b2d0d
5 changed files with 27 additions and 0 deletions
|
@ -109,6 +109,7 @@ Grammar(
|
|||
"ARRAY_TYPE",
|
||||
"SLICE_TYPE",
|
||||
"REFERENCE_TYPE",
|
||||
"PLACEHOLDER_TYPE",
|
||||
|
||||
"EXTERN_BLOCK",
|
||||
"ENUM_VARIANT",
|
||||
|
|
|
@ -7,6 +7,7 @@ pub(super) fn type_(p: &mut Parser) {
|
|||
STAR => pointer_type(p),
|
||||
L_BRACK => array_or_slice_type(p),
|
||||
AMPERSAND => reference_type(p),
|
||||
UNDERSCORE => placeholder_type(p),
|
||||
IDENT => path_type(p),
|
||||
_ => {
|
||||
p.error("expected type");
|
||||
|
@ -130,6 +131,15 @@ fn reference_type(p: &mut Parser) {
|
|||
m.complete(p, REFERENCE_TYPE);
|
||||
}
|
||||
|
||||
// test placeholder_type
|
||||
// type Placeholder = _;
|
||||
fn placeholder_type(p: &mut Parser) {
|
||||
assert!(p.at(UNDERSCORE));
|
||||
let m = p.start();
|
||||
p.bump();
|
||||
m.complete(p, PLACEHOLDER_TYPE);
|
||||
}
|
||||
|
||||
fn path_type(p: &mut Parser) {
|
||||
assert!(p.at(IDENT));
|
||||
let m = p.start();
|
||||
|
|
|
@ -107,6 +107,7 @@ pub enum SyntaxKind {
|
|||
ARRAY_TYPE,
|
||||
SLICE_TYPE,
|
||||
REFERENCE_TYPE,
|
||||
PLACEHOLDER_TYPE,
|
||||
EXTERN_BLOCK,
|
||||
ENUM_VARIANT,
|
||||
NAMED_FIELD,
|
||||
|
@ -240,6 +241,7 @@ impl SyntaxKind {
|
|||
ARRAY_TYPE => &SyntaxInfo { name: "ARRAY_TYPE" },
|
||||
SLICE_TYPE => &SyntaxInfo { name: "SLICE_TYPE" },
|
||||
REFERENCE_TYPE => &SyntaxInfo { name: "REFERENCE_TYPE" },
|
||||
PLACEHOLDER_TYPE => &SyntaxInfo { name: "PLACEHOLDER_TYPE" },
|
||||
EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" },
|
||||
ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" },
|
||||
NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" },
|
||||
|
|
1
tests/data/parser/inline/0027_placeholder_type.rs
Normal file
1
tests/data/parser/inline/0027_placeholder_type.rs
Normal file
|
@ -0,0 +1 @@
|
|||
type Placeholder = _;
|
13
tests/data/parser/inline/0027_placeholder_type.txt
Normal file
13
tests/data/parser/inline/0027_placeholder_type.txt
Normal file
|
@ -0,0 +1,13 @@
|
|||
FILE@[0; 22)
|
||||
TYPE_ITEM@[0; 22)
|
||||
TYPE_KW@[0; 4)
|
||||
NAME@[4; 17)
|
||||
WHITESPACE@[4; 5)
|
||||
IDENT@[5; 16) "Placeholder"
|
||||
WHITESPACE@[16; 17)
|
||||
EQ@[17; 18)
|
||||
PLACEHOLDER_TYPE@[18; 20)
|
||||
WHITESPACE@[18; 19)
|
||||
UNDERSCORE@[19; 20)
|
||||
SEMI@[20; 21)
|
||||
WHITESPACE@[21; 22)
|
Loading…
Reference in a new issue