From 3b71646a600b44868ed6cd7e69d66617a24e41e2 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Wed, 2 Nov 2016 22:59:08 +0000 Subject: [PATCH] Revert "macros: Improve `tt` fragments" This reverts commit 41745f30f751364bdce14428b7d3ffa5dd028903. --- src/libsyntax/ext/tt/transcribe.rs | 16 +++------------- src/libsyntax/tokenstream.rs | 7 ------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 641d69900f7..9ca3b16b74e 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -13,7 +13,7 @@ use ast::Ident; use errors::{Handler, DiagnosticBuilder}; use ext::tt::macro_parser::{NamedMatch, MatchedSeq, MatchedNonterminal}; use parse::token::{DocComment, MatchNt, SubstNt}; -use parse::token::{Token, Interpolated, NtIdent, NtTT}; +use parse::token::{Token, NtIdent}; use parse::token; use parse::lexer::TokenAndSpan; use syntax_pos::{Span, DUMMY_SP}; @@ -269,9 +269,9 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { } // FIXME #2887: think about span stuff here TokenTree::Token(sp, SubstNt(ident)) => { + r.stack.last_mut().unwrap().idx += 1; match lookup_cur_matched(r, ident) { None => { - r.stack.last_mut().unwrap().idx += 1; r.cur_span = sp; r.cur_tok = SubstNt(ident); return ret_val; @@ -283,24 +283,14 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { // (a) idents can be in lots of places, so it'd be a pain // (b) we actually can, since it's a token. NtIdent(ref sn) => { - r.stack.last_mut().unwrap().idx += 1; r.cur_span = sn.span; r.cur_tok = token::Ident(sn.node); return ret_val; } - NtTT(_) => { - r.stack.push(TtFrame { - forest: TokenTree::Token(sp, Interpolated(nt.clone())), - idx: 0, - dotdotdoted: false, - sep: None, - }); - } _ => { - r.stack.last_mut().unwrap().idx += 1; // FIXME(pcwalton): Bad copy. r.cur_span = sp; - r.cur_tok = Interpolated(nt.clone()); + r.cur_tok = token::Interpolated(nt.clone()); return ret_val; } } diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index a0dd7b4c521..204c885e361 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -195,13 +195,6 @@ impl TokenTree { TokenTree::Token(sp, token::Ident(kind))]; v[index].clone() } - (&TokenTree::Token(_, token::Interpolated(ref nt)), _) => { - if let Nonterminal::NtTT(ref tt) = **nt { - tt.clone() - } else { - panic!("Cannot expand a token tree"); - } - } (&TokenTree::Sequence(_, ref seq), _) => seq.tts[index].clone(), _ => panic!("Cannot expand a token tree"), }