diff options
| author | bors <bors@rust-lang.org> | 2020-02-12 16:25:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-02-12 16:25:13 +0000 |
| commit | 2d2be570970d784db5539a1d309cd22b85be910a (patch) | |
| tree | 52c9407b54a2b5c06af608699528a311406a4e78 /src/librustc_parse/parser/expr.rs | |
| parent | 2ed25f069768c046464e68fd382c867ddb04a1e3 (diff) | |
| parent | d9982f1f817e67149316b60fbacb0425e7179365 (diff) | |
| download | rust-2d2be570970d784db5539a1d309cd22b85be910a.tar.gz rust-2d2be570970d784db5539a1d309cd22b85be910a.zip | |
Auto merge of #69094 - Dylan-DPC:rollup-4qe7uv1, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - #67585 (Improve `char::is_ascii_*` codegen) - #68914 (Speed up `SipHasher128`.) - #68994 (rustbuild: include channel in sanitizers installed name) - #69032 (ICE in nightly-2020-02-08: handle TerminatorKind::Yield in librustc_mir::transform::promote_consts::Validator method) - #69034 (parser: Remove `Parser::prev_token_kind`) - #69042 (Remove backtrace header text) - #69059 (Remove a few unused objects) - #69089 (Properly use the darwin archive format on Apple targets) Failed merges: r? @ghost
Diffstat (limited to 'src/librustc_parse/parser/expr.rs')
| -rw-r--r-- | src/librustc_parse/parser/expr.rs | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs index eacc95e0395..c8c0ba4c66e 100644 --- a/src/librustc_parse/parser/expr.rs +++ b/src/librustc_parse/parser/expr.rs @@ -1,6 +1,6 @@ use super::pat::{GateOr, PARAM_EXPECTED}; use super::ty::{AllowPlus, RecoverQPath}; -use super::{BlockMode, Parser, PathStyle, PrevTokenKind, Restrictions, TokenType}; +use super::{BlockMode, Parser, PathStyle, Restrictions, TokenType}; use super::{SemiColonMode, SeqSep, TokenExpectType}; use crate::maybe_recover_from_interpolated_ty_qpath; @@ -166,17 +166,10 @@ impl<'a> Parser<'a> { self.expected_tokens.push(TokenType::Operator); while let Some(op) = self.check_assoc_op() { - // Adjust the span for interpolated LHS to point to the `$lhs` token and not to what - // it refers to. Interpolated identifiers are unwrapped early and never show up here - // as `PrevTokenKind::Interpolated` so if LHS is a single identifier we always process - // it as "interpolated", it doesn't change the answer for non-interpolated idents. - let lhs_span = match (self.prev_token_kind, &lhs.kind) { - (PrevTokenKind::Interpolated, _) => self.prev_span, - (PrevTokenKind::Ident, &ExprKind::Path(None, ref path)) - if path.segments.len() == 1 => - { - self.prev_span - } + // Adjust the span for interpolated LHS to point to the `$lhs` token + // and not to what it refers to. + let lhs_span = match self.unnormalized_prev_token().kind { + TokenKind::Interpolated(..) => self.prev_span, _ => lhs.span, }; @@ -535,11 +528,13 @@ impl<'a> Parser<'a> { expr: PResult<'a, P<Expr>>, ) -> PResult<'a, (Span, P<Expr>)> { expr.map(|e| { - if self.prev_token_kind == PrevTokenKind::Interpolated { - (self.prev_span, e) - } else { - (e.span, e) - } + ( + match self.unnormalized_prev_token().kind { + TokenKind::Interpolated(..) => self.prev_span, + _ => e.span, + }, + e, + ) }) } |
