diff options
Diffstat (limited to 'src/parser')
-rw-r--r-- | src/parser/grammar/types.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/parser/grammar/types.rs b/src/parser/grammar/types.rs index 4eb333b54..003341db5 100644 --- a/src/parser/grammar/types.rs +++ b/src/parser/grammar/types.rs | |||
@@ -6,6 +6,7 @@ pub(super) fn type_(p: &mut Parser) { | |||
6 | EXCL => never_type(p), | 6 | EXCL => never_type(p), |
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 | IDENT => path_type(p), | 10 | IDENT => path_type(p), |
10 | _ => { | 11 | _ => { |
11 | p.error("expected type"); | 12 | p.error("expected type"); |
@@ -115,6 +116,20 @@ fn array_or_slice_type(p: &mut Parser) { | |||
115 | m.complete(p, kind); | 116 | m.complete(p, kind); |
116 | } | 117 | } |
117 | 118 | ||
119 | // test reference_type; | ||
120 | // type A = &(); | ||
121 | // type B = &'static (); | ||
122 | // type C = &mut (); | ||
123 | fn reference_type(p: &mut Parser) { | ||
124 | assert!(p.at(AMPERSAND)); | ||
125 | let m = p.start(); | ||
126 | p.bump(); | ||
127 | p.eat(LIFETIME); | ||
128 | p.eat(MUT_KW); | ||
129 | type_no_plus(p); | ||
130 | m.complete(p, REFERENCE_TYPE); | ||
131 | } | ||
132 | |||
118 | fn path_type(p: &mut Parser) { | 133 | fn path_type(p: &mut Parser) { |
119 | assert!(p.at(IDENT)); | 134 | assert!(p.at(IDENT)); |
120 | let m = p.start(); | 135 | let m = p.start(); |