From 5e693531ffa55cfb0cececdf5d7203a6d400e828 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 5 Jun 2019 09:39:34 +0300 Subject: syntax: Add some helper methods to `Token` --- src/libsyntax/ext/tt/macro_parser.rs | 13 ++++++------- src/libsyntax/ext/tt/quoted.rs | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 4f681a77ed3..7127acabb44 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -727,13 +727,12 @@ pub fn parse( "ambiguity: multiple successful parses".to_string(), ); } else { - let span = if parser.span.is_dummy() { - parser.span - } else { - sess.source_map().next_point(parser.span) - }; return Failure( - Token { kind: token::Eof, span }, + Token::new(token::Eof, if parser.span.is_dummy() { + parser.span + } else { + sess.source_map().next_point(parser.span) + }), "missing tokens in macro arguments", ); } @@ -771,7 +770,7 @@ pub fn parse( // then there is a syntax error. else if bb_items.is_empty() && next_items.is_empty() { return Failure( - parser.token.clone(), + parser.token.take(), "no rules expected this token in macro call", ); } diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index 9f4e35ad3d7..558b07af611 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -154,7 +154,7 @@ impl TokenTree { } crate fn token(span: Span, kind: TokenKind) -> TokenTree { - TokenTree::Token(Token { kind, span }) + TokenTree::Token(Token::new(kind, span)) } } -- cgit 1.4.1-3-g733a5