diff options
| author | bors <bors@rust-lang.org> | 2019-06-07 06:52:09 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-06-07 06:52:09 +0000 |
| commit | ca1bcfdde3f19afd68ef808cecf2ce56d08d5df4 (patch) | |
| tree | 07a0d2ef9340fa064341cc697a8ae58e3762373a /src/libsyntax/util | |
| parent | c5295ac64a8f2c7aee9cdd13b8fe00b82aff8435 (diff) | |
| parent | 3a31f0634bb1669eae64e83f595942986f867125 (diff) | |
| download | rust-ca1bcfdde3f19afd68ef808cecf2ce56d08d5df4.tar.gz rust-ca1bcfdde3f19afd68ef808cecf2ce56d08d5df4.zip | |
Auto merge of #61541 - petrochenkov:tsp, r=oli-obk
syntax: Keep token span as a part of `Token` In the world with proc macros and edition hygiene `Token` without a span is not self-contained. In practice this means that tokens and spans are always stored and passed somewhere along with each other. This PR combines them into a single struct by doing the next renaming/replacement: - `Token` -> `TokenKind` - `TokenAndSpan` -> `Token` - `(Token, Span)` -> `Token` Some later commits (https://github.com/rust-lang/rust/commit/fb6e2fe8fd6caed247857758c6c3549fe2b59527 and https://github.com/rust-lang/rust/commit/1cdee86940db892cd17239c26add5364335e895a) remove duplicate spans in `token::Ident` and `token::Lifetime`. Those spans were supposed to be identical to token spans, but could easily go out of sync, as was noticed in https://github.com/rust-lang/rust/pull/60965#discussion_r285398523. The `(Token, Span)` -> `Token` change is a soft pre-requisite for this de-duplication since it allows to avoid some larger churn (passing spans to most of functions classifying identifiers).
Diffstat (limited to 'src/libsyntax/util')
| -rw-r--r-- | src/libsyntax/util/parser.rs | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/libsyntax/util/parser.rs b/src/libsyntax/util/parser.rs index 7e306d59e35..9e26f1bf7d3 100644 --- a/src/libsyntax/util/parser.rs +++ b/src/libsyntax/util/parser.rs @@ -1,4 +1,4 @@ -use crate::parse::token::{Token, BinOpToken}; +use crate::parse::token::{self, TokenKind, BinOpToken}; use crate::symbol::kw; use crate::ast::{self, BinOpKind}; @@ -69,34 +69,34 @@ pub enum Fixity { impl AssocOp { /// Creates a new AssocOP from a token - pub fn from_token(t: &Token) -> Option<AssocOp> { + pub fn from_token(t: &TokenKind) -> Option<AssocOp> { use AssocOp::*; match *t { - Token::BinOpEq(k) => Some(AssignOp(k)), - Token::Eq => Some(Assign), - Token::BinOp(BinOpToken::Star) => Some(Multiply), - Token::BinOp(BinOpToken::Slash) => Some(Divide), - Token::BinOp(BinOpToken::Percent) => Some(Modulus), - Token::BinOp(BinOpToken::Plus) => Some(Add), - Token::BinOp(BinOpToken::Minus) => Some(Subtract), - Token::BinOp(BinOpToken::Shl) => Some(ShiftLeft), - Token::BinOp(BinOpToken::Shr) => Some(ShiftRight), - Token::BinOp(BinOpToken::And) => Some(BitAnd), - Token::BinOp(BinOpToken::Caret) => Some(BitXor), - Token::BinOp(BinOpToken::Or) => Some(BitOr), - Token::Lt => Some(Less), - Token::Le => Some(LessEqual), - Token::Ge => Some(GreaterEqual), - Token::Gt => Some(Greater), - Token::EqEq => Some(Equal), - Token::Ne => Some(NotEqual), - Token::AndAnd => Some(LAnd), - Token::OrOr => Some(LOr), - Token::DotDot => Some(DotDot), - Token::DotDotEq => Some(DotDotEq), + token::BinOpEq(k) => Some(AssignOp(k)), + token::Eq => Some(Assign), + token::BinOp(BinOpToken::Star) => Some(Multiply), + token::BinOp(BinOpToken::Slash) => Some(Divide), + token::BinOp(BinOpToken::Percent) => Some(Modulus), + token::BinOp(BinOpToken::Plus) => Some(Add), + token::BinOp(BinOpToken::Minus) => Some(Subtract), + token::BinOp(BinOpToken::Shl) => Some(ShiftLeft), + token::BinOp(BinOpToken::Shr) => Some(ShiftRight), + token::BinOp(BinOpToken::And) => Some(BitAnd), + token::BinOp(BinOpToken::Caret) => Some(BitXor), + token::BinOp(BinOpToken::Or) => Some(BitOr), + token::Lt => Some(Less), + token::Le => Some(LessEqual), + token::Ge => Some(GreaterEqual), + token::Gt => Some(Greater), + token::EqEq => Some(Equal), + token::Ne => Some(NotEqual), + token::AndAnd => Some(LAnd), + token::OrOr => Some(LOr), + token::DotDot => Some(DotDot), + token::DotDotEq => Some(DotDotEq), // DotDotDot is no longer supported, but we need some way to display the error - Token::DotDotDot => Some(DotDotEq), - Token::Colon => Some(Colon), + token::DotDotDot => Some(DotDotEq), + token::Colon => Some(Colon), _ if t.is_keyword(kw::As) => Some(As), _ => None } |
