diff options
-rw-r--r-- | grammar.ron | 1 | ||||
-rw-r--r-- | src/parser/grammar/types.rs | 12 | ||||
-rw-r--r-- | src/syntax_kinds.rs | 2 | ||||
-rw-r--r-- | tests/data/parser/inline/0031_for_type.rs | 1 | ||||
-rw-r--r-- | tests/data/parser/inline/0031_for_type.txt | 29 |
5 files changed, 45 insertions, 0 deletions
diff --git a/grammar.ron b/grammar.ron index d5ad59553..fbb3c384a 100644 --- a/grammar.ron +++ b/grammar.ron | |||
@@ -111,6 +111,7 @@ Grammar( | |||
111 | "REFERENCE_TYPE", | 111 | "REFERENCE_TYPE", |
112 | "PLACEHOLDER_TYPE", | 112 | "PLACEHOLDER_TYPE", |
113 | "FN_POINTER_TYPE", | 113 | "FN_POINTER_TYPE", |
114 | "FOR_TYPE", | ||
114 | 115 | ||
115 | "EXTERN_BLOCK", | 116 | "EXTERN_BLOCK", |
116 | "ENUM_VARIANT", | 117 | "ENUM_VARIANT", |
diff --git a/src/parser/grammar/types.rs b/src/parser/grammar/types.rs index a4967a00a..c25517a51 100644 --- a/src/parser/grammar/types.rs +++ b/src/parser/grammar/types.rs | |||
@@ -9,6 +9,7 @@ pub(super) fn type_(p: &mut Parser) { | |||
9 | AMPERSAND => reference_type(p), | 9 | AMPERSAND => reference_type(p), |
10 | UNDERSCORE => placeholder_type(p), | 10 | UNDERSCORE => placeholder_type(p), |
11 | FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p), | 11 | FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p), |
12 | FOR_KW => for_type(p), | ||
12 | IDENT => path_type(p), | 13 | IDENT => path_type(p), |
13 | _ => { | 14 | _ => { |
14 | p.error("expected type"); | 15 | p.error("expected type"); |
@@ -166,6 +167,17 @@ fn fn_pointer_type(p: &mut Parser) { | |||
166 | m.complete(p, FN_POINTER_TYPE); | 167 | m.complete(p, FN_POINTER_TYPE); |
167 | } | 168 | } |
168 | 169 | ||
170 | // test for_type | ||
171 | // type A = for<'a> fn() -> (); | ||
172 | fn for_type(p: &mut Parser) { | ||
173 | assert!(p.at(FOR_KW)); | ||
174 | let m = p.start(); | ||
175 | p.bump(); | ||
176 | type_params::list(p); | ||
177 | type_(p); | ||
178 | m.complete(p, FOR_TYPE); | ||
179 | } | ||
180 | |||
169 | fn path_type(p: &mut Parser) { | 181 | fn path_type(p: &mut Parser) { |
170 | assert!(p.at(IDENT)); | 182 | assert!(p.at(IDENT)); |
171 | let m = p.start(); | 183 | let m = p.start(); |
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs index db0f51beb..537a80417 100644 --- a/src/syntax_kinds.rs +++ b/src/syntax_kinds.rs | |||
@@ -109,6 +109,7 @@ pub enum SyntaxKind { | |||
109 | REFERENCE_TYPE, | 109 | REFERENCE_TYPE, |
110 | PLACEHOLDER_TYPE, | 110 | PLACEHOLDER_TYPE, |
111 | FN_POINTER_TYPE, | 111 | FN_POINTER_TYPE, |
112 | FOR_TYPE, | ||
112 | EXTERN_BLOCK, | 113 | EXTERN_BLOCK, |
113 | ENUM_VARIANT, | 114 | ENUM_VARIANT, |
114 | NAMED_FIELD, | 115 | NAMED_FIELD, |
@@ -244,6 +245,7 @@ impl SyntaxKind { | |||
244 | REFERENCE_TYPE => &SyntaxInfo { name: "REFERENCE_TYPE" }, | 245 | REFERENCE_TYPE => &SyntaxInfo { name: "REFERENCE_TYPE" }, |
245 | PLACEHOLDER_TYPE => &SyntaxInfo { name: "PLACEHOLDER_TYPE" }, | 246 | PLACEHOLDER_TYPE => &SyntaxInfo { name: "PLACEHOLDER_TYPE" }, |
246 | FN_POINTER_TYPE => &SyntaxInfo { name: "FN_POINTER_TYPE" }, | 247 | FN_POINTER_TYPE => &SyntaxInfo { name: "FN_POINTER_TYPE" }, |
248 | FOR_TYPE => &SyntaxInfo { name: "FOR_TYPE" }, | ||
247 | EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" }, | 249 | EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" }, |
248 | ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" }, | 250 | ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" }, |
249 | NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" }, | 251 | NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" }, |
diff --git a/tests/data/parser/inline/0031_for_type.rs b/tests/data/parser/inline/0031_for_type.rs new file mode 100644 index 000000000..4d6a18c6b --- /dev/null +++ b/tests/data/parser/inline/0031_for_type.rs | |||
@@ -0,0 +1 @@ | |||
type A = for<'a> fn() -> (); | |||
diff --git a/tests/data/parser/inline/0031_for_type.txt b/tests/data/parser/inline/0031_for_type.txt new file mode 100644 index 000000000..0211950bc --- /dev/null +++ b/tests/data/parser/inline/0031_for_type.txt | |||
@@ -0,0 +1,29 @@ | |||
1 | FILE@[0; 29) | ||
2 | TYPE_ITEM@[0; 29) | ||
3 | TYPE_KW@[0; 4) | ||
4 | NAME@[4; 7) | ||
5 | WHITESPACE@[4; 5) | ||
6 | IDENT@[5; 6) "A" | ||
7 | WHITESPACE@[6; 7) | ||
8 | EQ@[7; 8) | ||
9 | FOR_TYPE@[8; 27) | ||
10 | WHITESPACE@[8; 9) | ||
11 | FOR_KW@[9; 12) | ||
12 | TYPE_PARAM_LIST@[12; 17) | ||
13 | L_ANGLE@[12; 13) | ||
14 | LIFETIME_PARAM@[13; 15) | ||
15 | LIFETIME@[13; 15) "'a" | ||
16 | R_ANGLE@[15; 16) | ||
17 | WHITESPACE@[16; 17) | ||
18 | FN_POINTER_TYPE@[17; 27) | ||
19 | FN_KW@[17; 19) | ||
20 | L_PAREN@[19; 20) | ||
21 | R_PAREN@[20; 21) | ||
22 | WHITESPACE@[21; 22) | ||
23 | THIN_ARROW@[22; 24) | ||
24 | TUPLE_TYPE@[24; 27) | ||
25 | WHITESPACE@[24; 25) | ||
26 | L_PAREN@[25; 26) | ||
27 | R_PAREN@[26; 27) | ||
28 | SEMI@[27; 28) | ||
29 | WHITESPACE@[28; 29) | ||