From 253a18f93893ffa0e2804937c913fed84df5f8d3 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Sat, 14 Sep 2019 15:59:24 -0700 Subject: Allow an underscore as the identifier in `const` items --- crates/ra_parser/src/grammar/items/consts.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'crates/ra_parser/src/grammar/items/consts.rs') 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) { assert!(p.at(kw)); p.bump_any(); p.eat(T![mut]); // FIXME: validator to forbid const mut - name(p); + + // Allow `_` in place of an identifier in a `const`. + let is_const_underscore = kw == T![const] && p.eat(T![_]); + if !is_const_underscore { + name(p); + } + + // test_err static_underscore + // static _: i32 = 5; + types::ascription(p); if p.eat(T![=]) { expressions::expr(p); -- cgit v1.2.3