aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--grammar.ron1
-rw-r--r--src/parser/grammar/types.rs10
-rw-r--r--src/syntax_kinds.rs2
-rw-r--r--tests/data/parser/inline/0027_placeholder_type.rs1
-rw-r--r--tests/data/parser/inline/0027_placeholder_type.txt13
5 files changed, 27 insertions, 0 deletions
diff --git a/grammar.ron b/grammar.ron
index 0905c282a..e3010b009 100644
--- a/grammar.ron
+++ b/grammar.ron
@@ -109,6 +109,7 @@ Grammar(
109 "ARRAY_TYPE", 109 "ARRAY_TYPE",
110 "SLICE_TYPE", 110 "SLICE_TYPE",
111 "REFERENCE_TYPE", 111 "REFERENCE_TYPE",
112 "PLACEHOLDER_TYPE",
112 113
113 "EXTERN_BLOCK", 114 "EXTERN_BLOCK",
114 "ENUM_VARIANT", 115 "ENUM_VARIANT",
diff --git a/src/parser/grammar/types.rs b/src/parser/grammar/types.rs
index 003341db5..37b74bfe7 100644
--- a/src/parser/grammar/types.rs
+++ b/src/parser/grammar/types.rs
@@ -7,6 +7,7 @@ pub(super) fn type_(p: &mut Parser) {
7 STAR => pointer_type(p), 7 STAR => pointer_type(p),
8 L_BRACK => array_or_slice_type(p), 8 L_BRACK => array_or_slice_type(p),
9 AMPERSAND => reference_type(p), 9 AMPERSAND => reference_type(p),
10 UNDERSCORE => placeholder_type(p),
10 IDENT => path_type(p), 11 IDENT => path_type(p),
11 _ => { 12 _ => {
12 p.error("expected type"); 13 p.error("expected type");
@@ -130,6 +131,15 @@ fn reference_type(p: &mut Parser) {
130 m.complete(p, REFERENCE_TYPE); 131 m.complete(p, REFERENCE_TYPE);
131} 132}
132 133
134// test placeholder_type
135// type Placeholder = _;
136fn placeholder_type(p: &mut Parser) {
137 assert!(p.at(UNDERSCORE));
138 let m = p.start();
139 p.bump();
140 m.complete(p, PLACEHOLDER_TYPE);
141}
142
133fn path_type(p: &mut Parser) { 143fn path_type(p: &mut Parser) {
134 assert!(p.at(IDENT)); 144 assert!(p.at(IDENT));
135 let m = p.start(); 145 let m = p.start();
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs
index 597550a32..73539d6d4 100644
--- a/src/syntax_kinds.rs
+++ b/src/syntax_kinds.rs
@@ -107,6 +107,7 @@ pub enum SyntaxKind {
107 ARRAY_TYPE, 107 ARRAY_TYPE,
108 SLICE_TYPE, 108 SLICE_TYPE,
109 REFERENCE_TYPE, 109 REFERENCE_TYPE,
110 PLACEHOLDER_TYPE,
110 EXTERN_BLOCK, 111 EXTERN_BLOCK,
111 ENUM_VARIANT, 112 ENUM_VARIANT,
112 NAMED_FIELD, 113 NAMED_FIELD,
@@ -240,6 +241,7 @@ impl SyntaxKind {
240 ARRAY_TYPE => &SyntaxInfo { name: "ARRAY_TYPE" }, 241 ARRAY_TYPE => &SyntaxInfo { name: "ARRAY_TYPE" },
241 SLICE_TYPE => &SyntaxInfo { name: "SLICE_TYPE" }, 242 SLICE_TYPE => &SyntaxInfo { name: "SLICE_TYPE" },
242 REFERENCE_TYPE => &SyntaxInfo { name: "REFERENCE_TYPE" }, 243 REFERENCE_TYPE => &SyntaxInfo { name: "REFERENCE_TYPE" },
244 PLACEHOLDER_TYPE => &SyntaxInfo { name: "PLACEHOLDER_TYPE" },
243 EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" }, 245 EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" },
244 ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" }, 246 ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" },
245 NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" }, 247 NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" },
diff --git a/tests/data/parser/inline/0027_placeholder_type.rs b/tests/data/parser/inline/0027_placeholder_type.rs
new file mode 100644
index 000000000..7952dbd57
--- /dev/null
+++ b/tests/data/parser/inline/0027_placeholder_type.rs
@@ -0,0 +1 @@
type Placeholder = _;
diff --git a/tests/data/parser/inline/0027_placeholder_type.txt b/tests/data/parser/inline/0027_placeholder_type.txt
new file mode 100644
index 000000000..ab848836c
--- /dev/null
+++ b/tests/data/parser/inline/0027_placeholder_type.txt
@@ -0,0 +1,13 @@
1FILE@[0; 22)
2 TYPE_ITEM@[0; 22)
3 TYPE_KW@[0; 4)
4 NAME@[4; 17)
5 WHITESPACE@[4; 5)
6 IDENT@[5; 16) "Placeholder"
7 WHITESPACE@[16; 17)
8 EQ@[17; 18)
9 PLACEHOLDER_TYPE@[18; 20)
10 WHITESPACE@[18; 19)
11 UNDERSCORE@[19; 20)
12 SEMI@[20; 21)
13 WHITESPACE@[21; 22)