diff options
| author | Donato Sciarra <sciarp@gmail.com> | 2018-10-12 00:34:26 +0200 |
|---|---|---|
| committer | Donato Sciarra <sciarp@gmail.com> | 2018-10-14 10:14:58 +0200 |
| commit | 406cbf1a39c99ef7b7f329a44f1d1c7af7a8ecda (patch) | |
| tree | 31e635b051152e1311f8da7ef50cc1d92607da1b /src/libsyntax/parse | |
| parent | 2bab4bf486aca3c3ba105e9931f56f6ddf445c3d (diff) | |
| download | rust-406cbf1a39c99ef7b7f329a44f1d1c7af7a8ecda.tar.gz rust-406cbf1a39c99ef7b7f329a44f1d1c7af7a8ecda.zip | |
Support underscore as constant name
Issue: 54912
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b5896f37c00..c7089a295fc 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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)?; |
