aboutsummaryrefslogtreecommitdiff
path: root/src/parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser')
-rw-r--r--src/parser/grammar/items/consts.rs2
-rw-r--r--src/parser/grammar/items/mod.rs2
-rw-r--r--src/parser/grammar/items/structs.rs4
-rw-r--r--src/parser/grammar/type_params.rs2
-rw-r--r--src/parser/grammar/types.rs18
5 files changed, 19 insertions, 9 deletions
diff --git a/src/parser/grammar/items/consts.rs b/src/parser/grammar/items/consts.rs
index 5f3cf58c2..d6c3753b3 100644
--- a/src/parser/grammar/items/consts.rs
+++ b/src/parser/grammar/items/consts.rs
@@ -14,7 +14,7 @@ fn const_or_static(p: &mut Parser, kw: SyntaxKind) {
14 p.eat(MUT_KW); // TODO: validator to forbid const mut 14 p.eat(MUT_KW); // TODO: validator to forbid const mut
15 name(p); 15 name(p);
16 p.expect(COLON); 16 p.expect(COLON);
17 types::ty(p); 17 types::type_(p);
18 p.expect(EQ); 18 p.expect(EQ);
19 expressions::expr(p); 19 expressions::expr(p);
20 p.expect(SEMI); 20 p.expect(SEMI);
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs
index f1776e0e2..b1edf2f22 100644
--- a/src/parser/grammar/items/mod.rs
+++ b/src/parser/grammar/items/mod.rs
@@ -247,7 +247,7 @@ fn type_item(p: &mut Parser) {
247 type_params::where_clause(p); 247 type_params::where_clause(p);
248 248
249 p.expect(EQ); 249 p.expect(EQ);
250 types::ty(p); 250 types::type_(p);
251 p.expect(SEMI); 251 p.expect(SEMI);
252} 252}
253 253
diff --git a/src/parser/grammar/items/structs.rs b/src/parser/grammar/items/structs.rs
index ad18fd270..c72b50808 100644
--- a/src/parser/grammar/items/structs.rs
+++ b/src/parser/grammar/items/structs.rs
@@ -89,7 +89,7 @@ fn named_fields(p: &mut Parser) {
89 if p.at(IDENT) { 89 if p.at(IDENT) {
90 name(p); 90 name(p);
91 p.expect(COLON); 91 p.expect(COLON);
92 types::ty(p); 92 types::type_(p);
93 field.complete(p, NAMED_FIELD); 93 field.complete(p, NAMED_FIELD);
94 } else { 94 } else {
95 field.abandon(p); 95 field.abandon(p);
@@ -105,7 +105,7 @@ fn pos_fields(p: &mut Parser) {
105 while !p.at(R_PAREN) && !p.at(EOF) { 105 while !p.at(R_PAREN) && !p.at(EOF) {
106 let pos_field = p.start(); 106 let pos_field = p.start();
107 visibility(p); 107 visibility(p);
108 types::ty(p); 108 types::type_(p);
109 pos_field.complete(p, POS_FIELD); 109 pos_field.complete(p, POS_FIELD);
110 110
111 if !p.at(R_PAREN) { 111 if !p.at(R_PAREN) {
diff --git a/src/parser/grammar/type_params.rs b/src/parser/grammar/type_params.rs
index 2462b260e..9ea08a55c 100644
--- a/src/parser/grammar/type_params.rs
+++ b/src/parser/grammar/type_params.rs
@@ -62,7 +62,7 @@ pub(super) fn list(p: &mut Parser) {
62 } 62 }
63 } 63 }
64 if p.at(EQ) { 64 if p.at(EQ) {
65 types::ty(p) 65 types::type_(p)
66 } 66 }
67 m.complete(p, TYPE_PARAM); 67 m.complete(p, TYPE_PARAM);
68 } 68 }
diff --git a/src/parser/grammar/types.rs b/src/parser/grammar/types.rs
index 71801d8ef..2ae583bd1 100644
--- a/src/parser/grammar/types.rs
+++ b/src/parser/grammar/types.rs
@@ -1,8 +1,9 @@
1use super::*; 1use super::*;
2 2
3pub(super) fn ty(p: &mut Parser) { 3pub(super) fn type_(p: &mut Parser) {
4 match p.current() { 4 match p.current() {
5 L_PAREN => paren_or_tuple_ty(p), 5 L_PAREN => paren_or_tuple_type(p),
6 EXCL => never_type(p),
6 IDENT => path_type(p), 7 IDENT => path_type(p),
7 _ => { 8 _ => {
8 p.error("expected type"); 9 p.error("expected type");
@@ -10,7 +11,7 @@ pub(super) fn ty(p: &mut Parser) {
10 } 11 }
11} 12}
12 13
13fn paren_or_tuple_ty(p: &mut Parser) { 14fn paren_or_tuple_type(p: &mut Parser) {
14 assert!(p.at(L_PAREN)); 15 assert!(p.at(L_PAREN));
15 let m = p.start(); 16 let m = p.start();
16 p.bump(); 17 p.bump();
@@ -18,7 +19,7 @@ fn paren_or_tuple_ty(p: &mut Parser) {
18 let mut trailing_comma: bool = false; 19 let mut trailing_comma: bool = false;
19 while !p.at(EOF) && !p.at(R_PAREN) { 20 while !p.at(EOF) && !p.at(R_PAREN) {
20 n_types += 1; 21 n_types += 1;
21 ty(p); 22 type_(p);
22 if p.eat(COMMA) { 23 if p.eat(COMMA) {
23 trailing_comma = true; 24 trailing_comma = true;
24 } else { 25 } else {
@@ -43,6 +44,15 @@ fn paren_or_tuple_ty(p: &mut Parser) {
43 m.complete(p, kind); 44 m.complete(p, kind);
44} 45}
45 46
47// test never_type
48// type Never = !;
49fn never_type(p: &mut Parser) {
50 assert!(p.at(EXCL));
51 let m = p.start();
52 p.bump();
53 m.complete(p, NEVER_TYPE);
54}
55
46fn path_type(p: &mut Parser) { 56fn path_type(p: &mut Parser) {
47 assert!(p.at(IDENT)); 57 assert!(p.at(IDENT));
48 let m = p.start(); 58 let m = p.start();