diff options
| author | bors <bors@rust-lang.org> | 2018-10-14 09:28:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-10-14 09:28:19 +0000 |
| commit | 2462a2de8c72e70fca250abe29255519b5fb892d (patch) | |
| tree | 4502c09777231e9c10d1baabfcaec2de88a68dd5 /src/libsyntax/parse | |
| parent | 1ebcb215fc1e9c2907529aae57fe49db4ac50e71 (diff) | |
| parent | 406cbf1a39c99ef7b7f329a44f1d1c7af7a8ecda (diff) | |
| download | rust-2462a2de8c72e70fca250abe29255519b5fb892d.tar.gz rust-2462a2de8c72e70fca250abe29255519b5fb892d.zip | |
Auto merge of #55015 - dsciarra:underscores-constant-names, r=petrochenkov
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)?; |
