Skip to content

Commit 3b71646

Browse files
committed
Revert "macros: Improve tt fragments"
This reverts commit 41745f3.
1 parent eb3ac29 commit 3b71646

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

src/libsyntax/ext/tt/transcribe.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use ast::Ident;
1313
use errors::{Handler, DiagnosticBuilder};
1414
use ext::tt::macro_parser::{NamedMatch, MatchedSeq, MatchedNonterminal};
1515
use parse::token::{DocComment, MatchNt, SubstNt};
16-
use parse::token::{Token, Interpolated, NtIdent, NtTT};
16+
use parse::token::{Token, NtIdent};
1717
use parse::token;
1818
use parse::lexer::TokenAndSpan;
1919
use syntax_pos::{Span, DUMMY_SP};
@@ -269,9 +269,9 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
269269
}
270270
// FIXME #2887: think about span stuff here
271271
TokenTree::Token(sp, SubstNt(ident)) => {
272+
r.stack.last_mut().unwrap().idx += 1;
272273
match lookup_cur_matched(r, ident) {
273274
None => {
274-
r.stack.last_mut().unwrap().idx += 1;
275275
r.cur_span = sp;
276276
r.cur_tok = SubstNt(ident);
277277
return ret_val;
@@ -283,24 +283,14 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
283283
// (a) idents can be in lots of places, so it'd be a pain
284284
// (b) we actually can, since it's a token.
285285
NtIdent(ref sn) => {
286-
r.stack.last_mut().unwrap().idx += 1;
287286
r.cur_span = sn.span;
288287
r.cur_tok = token::Ident(sn.node);
289288
return ret_val;
290289
}
291-
NtTT(_) => {
292-
r.stack.push(TtFrame {
293-
forest: TokenTree::Token(sp, Interpolated(nt.clone())),
294-
idx: 0,
295-
dotdotdoted: false,
296-
sep: None,
297-
});
298-
}
299290
_ => {
300-
r.stack.last_mut().unwrap().idx += 1;
301291
// FIXME(pcwalton): Bad copy.
302292
r.cur_span = sp;
303-
r.cur_tok = Interpolated(nt.clone());
293+
r.cur_tok = token::Interpolated(nt.clone());
304294
return ret_val;
305295
}
306296
}

src/libsyntax/tokenstream.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,6 @@ impl TokenTree {
195195
TokenTree::Token(sp, token::Ident(kind))];
196196
v[index].clone()
197197
}
198-
(&TokenTree::Token(_, token::Interpolated(ref nt)), _) => {
199-
if let Nonterminal::NtTT(ref tt) = **nt {
200-
tt.clone()
201-
} else {
202-
panic!("Cannot expand a token tree");
203-
}
204-
}
205198
(&TokenTree::Sequence(_, ref seq), _) => seq.tts[index].clone(),
206199
_ => panic!("Cannot expand a token tree"),
207200
}

0 commit comments

Comments
 (0)