mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-31 17:12:53 +00:00
Allow an underscore as the identifier in const
items
This commit is contained in:
parent
211171ffe6
commit
253a18f938
@ -258,7 +258,7 @@ fn items_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> {
|
||||
}
|
||||
T![enum] => nominal::enum_def(p, m),
|
||||
T![use] => use_item::use_item(p, m),
|
||||
T![const] if (la == IDENT || la == T![mut]) => consts::const_def(p, m),
|
||||
T![const] if (la == IDENT || la == T![_] || la == T![mut]) => consts::const_def(p, m),
|
||||
T![static] => consts::static_def(p, m),
|
||||
// test extern_block
|
||||
// extern {}
|
||||
|
@ -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);
|
||||
|
@ -0,0 +1 @@
|
||||
static _: i32 = 5;
|
Loading…
Reference in New Issue
Block a user