aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/parser/grammar/types.rs29
-rw-r--r--src/syntax_kinds.rs2
2 files changed, 31 insertions, 0 deletions
diff --git a/src/parser/grammar/types.rs b/src/parser/grammar/types.rs
index 2ae583bd1..ceadf5f96 100644
--- a/src/parser/grammar/types.rs
+++ b/src/parser/grammar/types.rs
@@ -4,6 +4,7 @@ pub(super) fn type_(p: &mut Parser) {
4 match p.current() { 4 match p.current() {
5 L_PAREN => paren_or_tuple_type(p), 5 L_PAREN => paren_or_tuple_type(p),
6 EXCL => never_type(p), 6 EXCL => never_type(p),
7 STAR => pointer_type(p),
7 IDENT => path_type(p), 8 IDENT => path_type(p),
8 _ => { 9 _ => {
9 p.error("expected type"); 10 p.error("expected type");
@@ -11,6 +12,10 @@ pub(super) fn type_(p: &mut Parser) {
11 } 12 }
12} 13}
13 14
15fn type_no_plus(p: &mut Parser) {
16 type_(p);
17}
18
14fn paren_or_tuple_type(p: &mut Parser) { 19fn paren_or_tuple_type(p: &mut Parser) {
15 assert!(p.at(L_PAREN)); 20 assert!(p.at(L_PAREN));
16 let m = p.start(); 21 let m = p.start();
@@ -53,6 +58,30 @@ fn never_type(p: &mut Parser) {
53 m.complete(p, NEVER_TYPE); 58 m.complete(p, NEVER_TYPE);
54} 59}
55 60
61fn pointer_type(p: &mut Parser) {
62 assert!(p.at(STAR));
63 let m = p.start();
64 p.bump();
65
66 match p.current() {
67 // test pointer_type_mut
68 // type M = *mut ();
69 // type C = *mut ();
70 MUT_KW | CONST_KW => p.bump(),
71 _ => {
72 // test pointer_type_no_mutability
73 // type T = *();
74 p.error(
75 "expected mut or const in raw pointer type \
76 (use `*mut T` or `*const T` as appropriate)"
77 );
78 }
79 };
80
81 type_no_plus(p);
82 m.complete(p, POINTER_TYPE);
83}
84
56fn path_type(p: &mut Parser) { 85fn path_type(p: &mut Parser) {
57 assert!(p.at(IDENT)); 86 assert!(p.at(IDENT));
58 let m = p.start(); 87 let m = p.start();
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs
index 630d3d2a5..181dcc63b 100644
--- a/src/syntax_kinds.rs
+++ b/src/syntax_kinds.rs
@@ -103,6 +103,7 @@ pub enum SyntaxKind {
103 TUPLE_TYPE, 103 TUPLE_TYPE,
104 NEVER_TYPE, 104 NEVER_TYPE,
105 PATH_TYPE, 105 PATH_TYPE,
106 POINTER_TYPE,
106 EXTERN_BLOCK, 107 EXTERN_BLOCK,
107 ENUM_VARIANT, 108 ENUM_VARIANT,
108 NAMED_FIELD, 109 NAMED_FIELD,
@@ -232,6 +233,7 @@ impl SyntaxKind {
232 TUPLE_TYPE => &SyntaxInfo { name: "TUPLE_TYPE" }, 233 TUPLE_TYPE => &SyntaxInfo { name: "TUPLE_TYPE" },
233 NEVER_TYPE => &SyntaxInfo { name: "NEVER_TYPE" }, 234 NEVER_TYPE => &SyntaxInfo { name: "NEVER_TYPE" },
234 PATH_TYPE => &SyntaxInfo { name: "PATH_TYPE" }, 235 PATH_TYPE => &SyntaxInfo { name: "PATH_TYPE" },
236 POINTER_TYPE => &SyntaxInfo { name: "POINTER_TYPE" },
235 EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" }, 237 EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" },
236 ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" }, 238 ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" },
237 NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" }, 239 NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" },