@@ -258,6 +258,7 @@ pub struct Parser<'a> {
258
258
pub tokens_consumed : usize ,
259
259
pub restrictions : Restrictions ,
260
260
pub quote_depth : usize , // not (yet) related to the quasiquoter
261
+ parsing_token_tree : bool ,
261
262
pub reader : Box < Reader +' a > ,
262
263
/// The set of seen errors about obsolete syntax. Used to suppress
263
264
/// extra detail when the same error is seen twice
@@ -374,6 +375,7 @@ impl<'a> Parser<'a> {
374
375
tokens_consumed : 0 ,
375
376
restrictions : Restrictions :: empty ( ) ,
376
377
quote_depth : 0 ,
378
+ parsing_token_tree : false ,
377
379
obsolete_set : HashSet :: new ( ) ,
378
380
mod_path_stack : Vec :: new ( ) ,
379
381
filename : filename,
@@ -2663,7 +2665,7 @@ impl<'a> Parser<'a> {
2663
2665
}
2664
2666
2665
2667
pub fn check_unknown_macro_variable ( & mut self ) {
2666
- if self . quote_depth == 0 {
2668
+ if self . quote_depth == 0 && ! self . parsing_token_tree {
2667
2669
match self . token {
2668
2670
token:: SubstNt ( name) =>
2669
2671
self . fatal ( & format ! ( "unknown macro variable `{}`" , name) ) . emit ( ) ,
@@ -2723,6 +2725,7 @@ impl<'a> Parser<'a> {
2723
2725
Err ( err)
2724
2726
} ,
2725
2727
token:: OpenDelim ( delim) => {
2728
+ let parsing_token_tree = :: std:: mem:: replace ( & mut self . parsing_token_tree , true ) ;
2726
2729
// The span for beginning of the delimited section
2727
2730
let pre_span = self . span ;
2728
2731
@@ -2787,6 +2790,7 @@ impl<'a> Parser<'a> {
2787
2790
_ => { }
2788
2791
}
2789
2792
2793
+ self . parsing_token_tree = parsing_token_tree;
2790
2794
Ok ( TokenTree :: Delimited ( span, Rc :: new ( Delimited {
2791
2795
delim : delim,
2792
2796
open_span : open_span,
0 commit comments