diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2018-01-19 19:57:10 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2018-02-01 15:06:20 -0800 |
| commit | c1383e4dc4bd6598f5d73d2d6b1054f61b2b99d4 (patch) | |
| tree | edf364f3770e1626b806a05c569ca8b57c3107cf /src/libsyntax/parse/parser.rs | |
| parent | 56733bc9f8302409a2b6110f422512923c878154 (diff) | |
| download | rust-c1383e4dc4bd6598f5d73d2d6b1054f61b2b99d4.tar.gz rust-c1383e4dc4bd6598f5d73d2d6b1054f61b2b99d4.zip | |
Add filtering options to `rustc_on_unimplemented`
- filter error on the evaluated value of `Self` - filter error on the evaluated value of the type arguments - add argument to include custom note in diagnostic - allow the parser to parse `Self` when processing attributes - add custom message to binops
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b3c485a85c0..9e8c4d3de22 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -762,13 +762,19 @@ impl<'a> Parser<'a> { } pub fn parse_ident(&mut self) -> PResult<'a, ast::Ident> { - self.parse_ident_common(true) + self.parse_ident_common(true, false) } - fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, ast::Ident> { + pub fn parse_ident_attr(&mut self) -> PResult<'a, ast::Ident> { + self.parse_ident_common(true, true) + } + + fn parse_ident_common(&mut self, recover: bool, accept_self: bool) -> PResult<'a, ast::Ident> { match self.token { token::Ident(i) => { - if self.token.is_reserved_ident() { + if self.token.is_reserved_ident() + && !(accept_self && i.name == keywords::SelfType.name()) + { let mut err = self.struct_span_err(self.span, &format!("expected identifier, found {}", self.this_token_descr())); @@ -2111,7 +2117,7 @@ impl<'a> Parser<'a> { self.bump(); Ok(Ident::with_empty_ctxt(name)) } else { - self.parse_ident_common(false) + self.parse_ident_common(false, false) } } @@ -2128,7 +2134,7 @@ impl<'a> Parser<'a> { hi = self.prev_span; (fieldname, self.parse_expr()?, false) } else { - let fieldname = self.parse_ident_common(false)?; + let fieldname = self.parse_ident_common(false, false)?; hi = self.prev_span; // Mimic `x: x` for the `x` field shorthand. |
