aboutsummaryrefslogtreecommitdiff
path: root/src/parser/grammar/items
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-02-10 11:23:41 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-02-10 11:23:41 +0000
commitb814d931514cdc250f9156dabd874edf685569d0 (patch)
tree6de85e5e662bc0c6eca78715496a02867da1eff9 /src/parser/grammar/items
parentc3b009b6d24225ad2add62fce8206918fceba3eb (diff)
parent199b3a1604095beee9eaeec541c8f158e85493ea (diff)
Merge #46
46: Names r=matklad a=matklad bors r+
Diffstat (limited to 'src/parser/grammar/items')
-rw-r--r--src/parser/grammar/items/consts.rs2
-rw-r--r--src/parser/grammar/items/mod.rs12
-rw-r--r--src/parser/grammar/items/structs.rs9
-rw-r--r--src/parser/grammar/items/traits.rs2
4 files changed, 13 insertions, 12 deletions
diff --git a/src/parser/grammar/items/consts.rs b/src/parser/grammar/items/consts.rs
index c9881d681..8117af706 100644
--- a/src/parser/grammar/items/consts.rs
+++ b/src/parser/grammar/items/consts.rs
@@ -12,7 +12,7 @@ fn const_or_static(p: &mut Parser, kw: SyntaxKind) {
12 assert!(p.at(kw)); 12 assert!(p.at(kw));
13 p.bump(); 13 p.bump();
14 p.eat(MUT_KW); // TODO: validator to forbid const mut 14 p.eat(MUT_KW); // TODO: validator to forbid const mut
15 p.expect(IDENT); 15 name(p);
16 p.expect(COLON); 16 p.expect(COLON);
17 types::type_ref(p); 17 types::type_ref(p);
18 p.expect(EQ); 18 p.expect(EQ);
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs
index ffe86fa97..8bb821fb6 100644
--- a/src/parser/grammar/items/mod.rs
+++ b/src/parser/grammar/items/mod.rs
@@ -196,8 +196,9 @@ fn extern_crate_item(p: &mut Parser) {
196 p.bump(); 196 p.bump();
197 assert!(p.at(CRATE_KW)); 197 assert!(p.at(CRATE_KW));
198 p.bump(); 198 p.bump();
199 199 name(p);
200 p.expect(IDENT) && alias(p) && p.expect(SEMI); 200 alias(p);
201 p.expect(SEMI);
201} 202}
202 203
203fn extern_block(p: &mut Parser) { 204fn extern_block(p: &mut Parser) {
@@ -210,7 +211,7 @@ fn fn_item(p: &mut Parser) {
210 assert!(p.at(FN_KW)); 211 assert!(p.at(FN_KW));
211 p.bump(); 212 p.bump();
212 213
213 p.expect(IDENT); 214 name(p);
214 if p.at(L_PAREN) { 215 if p.at(L_PAREN) {
215 fn_value_parameters(p); 216 fn_value_parameters(p);
216 } else { 217 } else {
@@ -235,7 +236,7 @@ fn type_item(p: &mut Parser) {
235 assert!(p.at(TYPE_KW)); 236 assert!(p.at(TYPE_KW));
236 p.bump(); 237 p.bump();
237 238
238 p.expect(IDENT); 239 name(p);
239 240
240 // test type_item_type_params 241 // test type_item_type_params
241 // type Result<T> = (); 242 // type Result<T> = ();
@@ -254,7 +255,8 @@ fn mod_item(p: &mut Parser) {
254 assert!(p.at(MOD_KW)); 255 assert!(p.at(MOD_KW));
255 p.bump(); 256 p.bump();
256 257
257 if p.expect(IDENT) && !p.eat(SEMI) { 258 name(p);
259 if !p.eat(SEMI) {
258 if p.expect(L_CURLY) { 260 if p.expect(L_CURLY) {
259 mod_contents(p, true); 261 mod_contents(p, true);
260 p.expect(R_CURLY); 262 p.expect(R_CURLY);
diff --git a/src/parser/grammar/items/structs.rs b/src/parser/grammar/items/structs.rs
index 640b940e4..eca0d2e64 100644
--- a/src/parser/grammar/items/structs.rs
+++ b/src/parser/grammar/items/structs.rs
@@ -4,9 +4,7 @@ pub(super) fn struct_item(p: &mut Parser) {
4 assert!(p.at(STRUCT_KW)); 4 assert!(p.at(STRUCT_KW));
5 p.bump(); 5 p.bump();
6 6
7 if !p.expect(IDENT) { 7 name(p);
8 return;
9 }
10 type_params::list(p); 8 type_params::list(p);
11 match p.current() { 9 match p.current() {
12 WHERE_KW => { 10 WHERE_KW => {
@@ -43,7 +41,7 @@ pub(super) fn struct_item(p: &mut Parser) {
43pub(super) fn enum_item(p: &mut Parser) { 41pub(super) fn enum_item(p: &mut Parser) {
44 assert!(p.at(ENUM_KW)); 42 assert!(p.at(ENUM_KW));
45 p.bump(); 43 p.bump();
46 p.expect(IDENT); 44 name(p);
47 type_params::list(p); 45 type_params::list(p);
48 type_params::where_clause(p); 46 type_params::where_clause(p);
49 if p.expect(L_CURLY) { 47 if p.expect(L_CURLY) {
@@ -88,7 +86,8 @@ fn named_fields(p: &mut Parser) {
88 fn named_field(p: &mut Parser) { 86 fn named_field(p: &mut Parser) {
89 let field = p.start(); 87 let field = p.start();
90 visibility(p); 88 visibility(p);
91 if p.expect(IDENT) { 89 if p.at(IDENT) {
90 name(p);
92 p.expect(COLON); 91 p.expect(COLON);
93 types::type_ref(p); 92 types::type_ref(p);
94 field.complete(p, NAMED_FIELD); 93 field.complete(p, NAMED_FIELD);
diff --git a/src/parser/grammar/items/traits.rs b/src/parser/grammar/items/traits.rs
index 3bef9639f..9961a88fe 100644
--- a/src/parser/grammar/items/traits.rs
+++ b/src/parser/grammar/items/traits.rs
@@ -3,7 +3,7 @@ use super::*;
3pub(super) fn trait_item(p: &mut Parser) { 3pub(super) fn trait_item(p: &mut Parser) {
4 assert!(p.at(TRAIT_KW)); 4 assert!(p.at(TRAIT_KW));
5 p.bump(); 5 p.bump();
6 p.expect(IDENT); 6 name(p);
7 p.expect(L_CURLY); 7 p.expect(L_CURLY);
8 p.expect(R_CURLY); 8 p.expect(R_CURLY);
9} 9}