diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-06-08 19:45:12 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-06-08 22:38:12 +0300 |
| commit | 0ca3c2f881fc4bc51bfa92f1adcd1b845b812534 (patch) | |
| tree | 872462c18de8b5bcfad199cb88eb2731305b3f12 /src/libsyntax/ext/tt | |
| parent | ffe23475cba4b933475715ff72ca0be6aea0a398 (diff) | |
| download | rust-0ca3c2f881fc4bc51bfa92f1adcd1b845b812534.tar.gz rust-0ca3c2f881fc4bc51bfa92f1adcd1b845b812534.zip | |
syntax: Move most of the `TokenKind` methods to `Token`
Diffstat (limited to 'src/libsyntax/ext/tt')
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/transcribe.rs | 4 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 1c7fdf995e1..9520adb9029 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -428,13 +428,13 @@ pub fn parse_failure_msg(tok: TokenKind) -> String { } /// Performs a token equality check, ignoring syntax context (that is, an unhygienic comparison) -fn token_name_eq(t1: &TokenKind, t2: &TokenKind) -> bool { - if let (Some((name1, is_raw1)), Some((name2, is_raw2))) = (t1.ident_name(), t2.ident_name()) { - name1 == name2 && is_raw1 == is_raw2 - } else if let (Some(name1), Some(name2)) = (t1.lifetime_name(), t2.lifetime_name()) { - name1 == name2 +fn token_name_eq(t1: &Token, t2: &Token) -> bool { + if let (Some((ident1, is_raw1)), Some((ident2, is_raw2))) = (t1.ident(), t2.ident()) { + ident1.name == ident2.name && is_raw1 == is_raw2 + } else if let (Some(ident1), Some(ident2)) = (t1.lifetime(), t2.lifetime()) { + ident1.name == ident2.name } else { - *t1 == *t2 + t1.kind == t2.kind } } @@ -712,7 +712,7 @@ pub fn parse( // If we reached the EOF, check that there is EXACTLY ONE possible matcher. Otherwise, // either the parse is ambiguous (which should never happen) or there is a syntax error. - if token_name_eq(&parser.token, &token::Eof) { + if parser.token == token::Eof { if eof_items.len() == 1 { let matches = eof_items[0] .matches diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 3408cefdf42..c51f4b20c31 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -4,7 +4,7 @@ use crate::ext::expand::Marker; use crate::ext::tt::macro_parser::{MatchedNonterminal, MatchedSeq, NamedMatch}; use crate::ext::tt::quoted; use crate::mut_visit::noop_visit_tt; -use crate::parse::token::{self, NtTT, Token, TokenKind}; +use crate::parse::token::{self, NtTT, Token}; use crate::tokenstream::{DelimSpan, TokenStream, TokenTree, TreeAndJoint}; use smallvec::{smallvec, SmallVec}; @@ -237,7 +237,7 @@ pub fn transcribe( Ident::new(ident.name, ident.span.apply_mark(cx.current_expansion.mark)); sp = sp.apply_mark(cx.current_expansion.mark); result.push(TokenTree::token(token::Dollar, sp).into()); - result.push(TokenTree::token(TokenKind::from_ast_ident(ident), sp).into()); + result.push(TokenTree::Token(Token::from_ast_ident(ident)).into()); } } |
