aboutsummaryrefslogtreecommitdiff
path: root/src/parser/grammar/types.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-02-11 08:01:00 +0000
committerAleksey Kladov <[email protected]>2018-02-11 08:01:00 +0000
commit2389cf96dd07d8c94da349b10f6f2b750707dfd9 (patch)
tree169041219a8b2ba592db7820dcfe988bf362b93b /src/parser/grammar/types.rs
parente19d038a0e1d9af8270450c5fe8fbbdf0f15cb24 (diff)
G: Never type
Diffstat (limited to 'src/parser/grammar/types.rs')
-rw-r--r--src/parser/grammar/types.rs18
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 @@
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();