aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/grammar/items/consts.rs5
-rw-r--r--src/grammar/items/mod.rs15
-rw-r--r--src/grammar/items/traits.rs10
3 files changed, 25 insertions, 5 deletions
diff --git a/src/grammar/items/consts.rs b/src/grammar/items/consts.rs
index ca26a7814..b11949b49 100644
--- a/src/grammar/items/consts.rs
+++ b/src/grammar/items/consts.rs
@@ -14,7 +14,8 @@ 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 types::ascription(p); 16 types::ascription(p);
17 p.expect(EQ); 17 if p.eat(EQ) {
18 expressions::expr(p); 18 expressions::expr(p);
19 }
19 p.expect(SEMI); 20 p.expect(SEMI);
20} 21}
diff --git a/src/grammar/items/mod.rs b/src/grammar/items/mod.rs
index 83f1833b5..824f1296c 100644
--- a/src/grammar/items/mod.rs
+++ b/src/grammar/items/mod.rs
@@ -240,7 +240,11 @@ fn fn_item(p: &mut Parser) {
240 // fn foo<T>() where T: Copy {} 240 // fn foo<T>() where T: Copy {}
241 type_params::where_clause(p); 241 type_params::where_clause(p);
242 242
243 expressions::block(p); 243 // test fn_decl
244 // trait T { fn foo(); }
245 if !p.eat(SEMI) {
246 expressions::block(p);
247 }
244} 248}
245 249
246// test type_item 250// test type_item
@@ -255,12 +259,17 @@ fn type_item(p: &mut Parser) {
255 // type Result<T> = (); 259 // type Result<T> = ();
256 type_params::type_param_list(p); 260 type_params::type_param_list(p);
257 261
262 if p.at(COLON) {
263 type_params::bounds(p);
264 }
265
258 // test type_item_where_clause 266 // test type_item_where_clause
259 // type Foo where Foo: Copy = (); 267 // type Foo where Foo: Copy = ();
260 type_params::where_clause(p); 268 type_params::where_clause(p);
261 269
262 p.expect(EQ); 270 if p.eat(EQ) {
263 types::type_(p); 271 types::type_(p);
272 }
264 p.expect(SEMI); 273 p.expect(SEMI);
265} 274}
266 275
diff --git a/src/grammar/items/traits.rs b/src/grammar/items/traits.rs
index 7c0935371..0b9fb2b0b 100644
--- a/src/grammar/items/traits.rs
+++ b/src/grammar/items/traits.rs
@@ -12,6 +12,16 @@ pub(super) fn trait_item(p: &mut Parser) {
12 } 12 }
13 type_params::where_clause(p); 13 type_params::where_clause(p);
14 p.expect(L_CURLY); 14 p.expect(L_CURLY);
15 // test trait_item_items
16 // impl F {
17 // type A: Clone;
18 // const B: i32;
19 // fn foo() {}
20 // fn bar(&self);
21 // }
22 while !p.at(EOF) && !p.at(R_CURLY) {
23 item_or_macro(p, true);
24 }
15 p.expect(R_CURLY); 25 p.expect(R_CURLY);
16} 26}
17 27