aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar/items/consts.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-03-18 09:32:28 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-03-18 09:32:28 +0000
commit1cd18f9237b6ac48ca8461307f2a4eaf273ee394 (patch)
tree7971e3753c74b98e0e5b4120adb8706a86d99e3e /crates/ra_parser/src/grammar/items/consts.rs
parent7c117567ab55046a9303fc7a6676a50008ad4f33 (diff)
parent76075c74103b3204ebc1bde54a330629d9e00811 (diff)
Merge #991
991: Use Marker argument for item parsers r=matklad a=pcpthm Before doing this for expressions, I found that the pattern (Marker argument) should be applied to the item parsers because visiblity and modifiers are parsed in a separate function. Fixed some parser bugs: - Fix pub_expr: `pub 42;` was allowed. - Fix incorrect parsing of crate::path: incorrectly parsed as `crate` as a visibility. Co-authored-by: pcpthm <[email protected]>
Diffstat (limited to 'crates/ra_parser/src/grammar/items/consts.rs')
-rw-r--r--crates/ra_parser/src/grammar/items/consts.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/ra_parser/src/grammar/items/consts.rs b/crates/ra_parser/src/grammar/items/consts.rs
index 5a5852f83..e6e6011c6 100644
--- a/crates/ra_parser/src/grammar/items/consts.rs
+++ b/crates/ra_parser/src/grammar/items/consts.rs
@@ -1,14 +1,14 @@
1use super::*; 1use super::*;
2 2
3pub(super) fn static_def(p: &mut Parser) { 3pub(super) fn static_def(p: &mut Parser, m: Marker) {
4 const_or_static(p, STATIC_KW) 4 const_or_static(p, m, STATIC_KW, STATIC_DEF)
5} 5}
6 6
7pub(super) fn const_def(p: &mut Parser) { 7pub(super) fn const_def(p: &mut Parser, m: Marker) {
8 const_or_static(p, CONST_KW) 8 const_or_static(p, m, CONST_KW, CONST_DEF)
9} 9}
10 10
11fn const_or_static(p: &mut Parser, kw: SyntaxKind) { 11fn const_or_static(p: &mut Parser, m: Marker, kw: SyntaxKind, def: 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
@@ -18,4 +18,5 @@ fn const_or_static(p: &mut Parser, kw: SyntaxKind) {
18 expressions::expr(p); 18 expressions::expr(p);
19 } 19 }
20 p.expect(SEMI); 20 p.expect(SEMI);
21 m.complete(p, def);
21} 22}