Support underscore as constant name

Issue: 54912
This commit is contained in:
Donato Sciarra
2018-10-12 00:34:26 +02:00
parent 2bab4bf486
commit 406cbf1a39
5 changed files with 100 additions and 1 deletions

View File

@@ -6346,7 +6346,13 @@ impl<'a> Parser<'a> {
}
fn parse_item_const(&mut self, m: Option<Mutability>) -> PResult<'a, ItemInfo> {
let id = self.parse_ident()?;
let id = match self.token {
token::Ident(ident, false) if ident.name == keywords::Underscore.name() => {
self.bump(); // `_`
ident.gensym()
},
_ => self.parse_ident()?,
};
self.expect(&token::Colon)?;
let ty = self.parse_ty()?;
self.expect(&token::Eq)?;