diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2020-03-07 15:58:27 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2020-03-09 12:42:41 +0300 |
| commit | 9be233cbfe134f032ed2d50f7cc66e901bbe3f6f (patch) | |
| tree | 29073f8d2cf134e40c898d69696095c26c123814 /src/librustc_parse | |
| parent | 5d7f67d3b109e95fb0dca8f773a2146db4eb4a93 (diff) | |
| download | rust-9be233cbfe134f032ed2d50f7cc66e901bbe3f6f.tar.gz rust-9be233cbfe134f032ed2d50f7cc66e901bbe3f6f.zip | |
Use `Token::uninterpolate` in couple more places matching on `(Nt)Ident`
Diffstat (limited to 'src/librustc_parse')
| -rw-r--r-- | src/librustc_parse/parser/expr.rs | 3 | ||||
| -rw-r--r-- | src/librustc_parse/parser/item.rs | 2 | ||||
| -rw-r--r-- | src/librustc_parse/parser/pat.rs | 2 |
3 files changed, 4 insertions, 3 deletions
diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs index f7cfb028a7a..d28b9cd9682 100644 --- a/src/librustc_parse/parser/expr.rs +++ b/src/librustc_parse/parser/expr.rs @@ -50,7 +50,6 @@ macro_rules! maybe_whole_expr { AttrVec::new(), )); } - // N.B., `NtIdent(ident)` is normalized to `Ident` in `fn bump`. _ => {} }; } @@ -482,7 +481,7 @@ impl<'a> Parser<'a> { } fn is_mistaken_not_ident_negation(&self) -> bool { - let token_cannot_continue_expr = |t: &Token| match t.kind { + let token_cannot_continue_expr = |t: &Token| match t.uninterpolate().kind { // These tokens can start an expression after `!`, but // can't continue an expression after an ident token::Ident(name, is_raw) => token::ident_can_begin_expr(name, t.span, is_raw), diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs index 08d71f03976..bf612bfc0e4 100644 --- a/src/librustc_parse/parser/item.rs +++ b/src/librustc_parse/parser/item.rs @@ -1544,6 +1544,8 @@ impl<'a> Parser<'a> { let is_name_required = match self.token.kind { token::DotDotDot => false, + // FIXME: Consider using interpolated token for this edition check, + // it should match the intent of edition hygiene better. _ => req_name(self.token.uninterpolate().span.edition()), }; let (pat, ty) = if is_name_required || self.is_named_param() { diff --git a/src/librustc_parse/parser/pat.rs b/src/librustc_parse/parser/pat.rs index 4c041fd669d..f52a91ff598 100644 --- a/src/librustc_parse/parser/pat.rs +++ b/src/librustc_parse/parser/pat.rs @@ -151,7 +151,7 @@ impl<'a> Parser<'a> { /// Note that there are more tokens such as `@` for which we know that the `|` /// is an illegal parse. However, the user's intent is less clear in that case. fn recover_trailing_vert(&mut self, lo: Option<Span>) -> bool { - let is_end_ahead = self.look_ahead(1, |token| match &token.kind { + let is_end_ahead = self.look_ahead(1, |token| match &token.uninterpolate().kind { token::FatArrow // e.g. `a | => 0,`. | token::Ident(kw::If, false) // e.g. `a | if expr`. | token::Eq // e.g. `let a | = 0`. |
