diff options
author | Dylan MacKenzie <[email protected]> | 2019-09-14 23:59:24 +0100 |
---|---|---|
committer | Dylan MacKenzie <[email protected]> | 2019-09-15 00:31:09 +0100 |
commit | 253a18f93893ffa0e2804937c913fed84df5f8d3 (patch) | |
tree | 9d039c8e9720fbc693f5a0a096014e1886226336 /crates/ra_parser/src/grammar/items | |
parent | 211171ffe6a4e8cbf31b9513972e59a8b9bdc811 (diff) |
Allow an underscore as the identifier in `const` items
Diffstat (limited to 'crates/ra_parser/src/grammar/items')
-rw-r--r-- | crates/ra_parser/src/grammar/items/consts.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/ra_parser/src/grammar/items/consts.rs b/crates/ra_parser/src/grammar/items/consts.rs index e11546333..63e0e6e0c 100644 --- a/crates/ra_parser/src/grammar/items/consts.rs +++ b/crates/ra_parser/src/grammar/items/consts.rs | |||
@@ -12,7 +12,16 @@ fn 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_any(); | 13 | p.bump_any(); |
14 | p.eat(T![mut]); // FIXME: validator to forbid const mut | 14 | p.eat(T![mut]); // FIXME: validator to forbid const mut |
15 | name(p); | 15 | |
16 | // Allow `_` in place of an identifier in a `const`. | ||
17 | let is_const_underscore = kw == T![const] && p.eat(T![_]); | ||
18 | if !is_const_underscore { | ||
19 | name(p); | ||
20 | } | ||
21 | |||
22 | // test_err static_underscore | ||
23 | // static _: i32 = 5; | ||
24 | |||
16 | types::ascription(p); | 25 | types::ascription(p); |
17 | if p.eat(T![=]) { | 26 | if p.eat(T![=]) { |
18 | expressions::expr(p); | 27 | expressions::expr(p); |