diff options
Diffstat (limited to 'src/parser/grammar/types.rs')
-rw-r--r-- | src/parser/grammar/types.rs | 18 |
1 files changed, 14 insertions, 4 deletions
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 @@ | |||
1 | use super::*; | 1 | use super::*; |
2 | 2 | ||
3 | pub(super) fn ty(p: &mut Parser) { | 3 | pub(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 | ||
13 | fn paren_or_tuple_ty(p: &mut Parser) { | 14 | fn 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 = !; | ||
49 | fn 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 | |||
46 | fn path_type(p: &mut Parser) { | 56 | fn 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(); |