@@ -14,7 +14,7 @@ use syntax_pos::{Span, DUMMY_SP};
14
14
use errors:: { Handler , DiagnosticBuilder } ;
15
15
use ext:: tt:: macro_parser:: { NamedMatch , MatchedSeq , MatchedNonterminal } ;
16
16
use parse:: token:: { DocComment , MatchNt , SubstNt } ;
17
- use parse:: token:: { Token , NtIdent , SpecialMacroVar } ;
17
+ use parse:: token:: { Token , Interpolated , NtIdent , NtTT , SpecialMacroVar } ;
18
18
use parse:: token;
19
19
use parse:: lexer:: TokenAndSpan ;
20
20
use tokenstream:: { self , TokenTree } ;
@@ -278,9 +278,9 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
278
278
}
279
279
// FIXME #2887: think about span stuff here
280
280
TokenTree :: Token ( sp, SubstNt ( ident) ) => {
281
- r. stack . last_mut ( ) . unwrap ( ) . idx += 1 ;
282
281
match lookup_cur_matched ( r, ident) {
283
282
None => {
283
+ r. stack . last_mut ( ) . unwrap ( ) . idx += 1 ;
284
284
r. cur_span = sp;
285
285
r. cur_tok = SubstNt ( ident) ;
286
286
return ret_val;
@@ -292,14 +292,24 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
292
292
// (a) idents can be in lots of places, so it'd be a pain
293
293
// (b) we actually can, since it's a token.
294
294
MatchedNonterminal ( NtIdent ( ref sn) ) => {
295
+ r. stack . last_mut ( ) . unwrap ( ) . idx += 1 ;
295
296
r. cur_span = sn. span ;
296
297
r. cur_tok = token:: Ident ( sn. node ) ;
297
298
return ret_val;
298
299
}
300
+ MatchedNonterminal ( NtTT ( ref tt) ) => {
301
+ r. stack . push ( TtFrame {
302
+ forest : TokenTree :: Token ( sp, Interpolated ( NtTT ( tt. clone ( ) ) ) ) ,
303
+ idx : 0 ,
304
+ dotdotdoted : false ,
305
+ sep : None ,
306
+ } ) ;
307
+ }
299
308
MatchedNonterminal ( ref other_whole_nt) => {
309
+ r. stack . last_mut ( ) . unwrap ( ) . idx += 1 ;
300
310
// FIXME(pcwalton): Bad copy.
301
311
r. cur_span = sp;
302
- r. cur_tok = token :: Interpolated ( ( * other_whole_nt) . clone ( ) ) ;
312
+ r. cur_tok = Interpolated ( ( * other_whole_nt) . clone ( ) ) ;
303
313
return ret_val;
304
314
}
305
315
MatchedSeq ( ..) => {
0 commit comments