@@ -392,7 +392,7 @@ pub fn compile_declarative_macro(
392392
393393    let  lhs_nm = Ident :: new ( sym:: lhs,  span) ; 
394394    let  rhs_nm = Ident :: new ( sym:: rhs,  span) ; 
395-     let  tt_spec = Some ( NonterminalKind :: TT ) ; 
395+     let  tt_spec = NonterminalKind :: TT ; 
396396    let  macro_rules = macro_def. macro_rules ; 
397397
398398    // Parse the macro_rules! invocation 
@@ -407,9 +407,9 @@ pub fn compile_declarative_macro(
407407            DelimSpan :: dummy( ) , 
408408            mbe:: SequenceRepetition  { 
409409                tts:  vec![ 
410-                     mbe:: TokenTree :: MetaVarDecl ( span,  lhs_nm,  tt_spec) , 
410+                     mbe:: TokenTree :: MetaVarDecl   {   span,  name :   lhs_nm,  kind :   tt_spec  } , 
411411                    mbe:: TokenTree :: token( token:: FatArrow ,  span) , 
412-                     mbe:: TokenTree :: MetaVarDecl ( span,  rhs_nm,  tt_spec) , 
412+                     mbe:: TokenTree :: MetaVarDecl   {   span,  name :   rhs_nm,  kind :   tt_spec  } , 
413413                ] , 
414414                separator:  Some ( Token :: new( 
415415                    if  macro_rules {  token:: Semi  }  else {  token:: Comma  } , 
@@ -448,6 +448,7 @@ pub fn compile_declarative_macro(
448448        match  tt_parser. parse_tt ( & mut  Cow :: Owned ( parser) ,  & argument_gram,  & mut  NoopTracker )  { 
449449            Success ( m)  => m, 
450450            Failure ( ( ) )  => { 
451+                 debug ! ( "failed to parse macro tt" ) ; 
451452                // The fast `NoopTracker` doesn't have any info on failure, so we need to retry it 
452453                // with another one that gives us the information we need. 
453454                // For this we need to reclone the macro body as the previous parser consumed it. 
@@ -616,7 +617,7 @@ fn is_empty_token_tree(sess: &Session, seq: &mbe::SequenceRepetition) -> bool {
616617        let  mut  iter = seq. tts . iter ( ) . peekable ( ) ; 
617618        while  let  Some ( tt)  = iter. next ( )  { 
618619            match  tt { 
619-                 mbe:: TokenTree :: MetaVarDecl ( _ ,  _ ,   Some ( NonterminalKind :: Vis ) )  => { } 
620+                 mbe:: TokenTree :: MetaVarDecl   {   kind :   NonterminalKind :: Vis ,  ..  }  => { } 
620621                mbe:: TokenTree :: Token ( t @ Token  {  kind :  DocComment ( ..) ,  .. } )  => { 
621622                    let  mut  now = t; 
622623                    while  let  Some ( & mbe:: TokenTree :: Token ( 
@@ -651,7 +652,7 @@ fn check_redundant_vis_repetition(
651652)  { 
652653    let  is_zero_or_one:  bool  = seq. kleene . op  == KleeneOp :: ZeroOrOne ; 
653654    let  is_vis = seq. tts . first ( ) . map_or ( false ,  |tt| { 
654-         matches ! ( tt,  mbe:: TokenTree :: MetaVarDecl ( _ ,  _ ,   Some ( NonterminalKind :: Vis ) ) ) 
655+         matches ! ( tt,  mbe:: TokenTree :: MetaVarDecl   {  kind :   NonterminalKind :: Vis ,  ..  } ) 
655656    } ) ; 
656657
657658    if  is_vis && is_zero_or_one { 
@@ -678,7 +679,7 @@ fn check_lhs_no_empty_seq(sess: &Session, tts: &[mbe::TokenTree]) -> Result<(),
678679        match  tt { 
679680            TokenTree :: Token ( ..) 
680681            | TokenTree :: MetaVar ( ..) 
681-             | TokenTree :: MetaVarDecl ( .. ) 
682+             | TokenTree :: MetaVarDecl   {  ..  } 
682683            | TokenTree :: MetaVarExpr ( ..)  => ( ) , 
683684            TokenTree :: Delimited ( ..,  del)  => check_lhs_no_empty_seq ( sess,  & del. tts ) ?, 
684685            TokenTree :: Sequence ( span,  seq)  => { 
@@ -777,7 +778,7 @@ impl<'tt> FirstSets<'tt> {
777778                match  tt { 
778779                    TokenTree :: Token ( ..) 
779780                    | TokenTree :: MetaVar ( ..) 
780-                     | TokenTree :: MetaVarDecl ( .. ) 
781+                     | TokenTree :: MetaVarDecl   {  ..  } 
781782                    | TokenTree :: MetaVarExpr ( ..)  => { 
782783                        first. replace_with ( TtHandle :: TtRef ( tt) ) ; 
783784                    } 
@@ -845,7 +846,7 @@ impl<'tt> FirstSets<'tt> {
845846            match  tt { 
846847                TokenTree :: Token ( ..) 
847848                | TokenTree :: MetaVar ( ..) 
848-                 | TokenTree :: MetaVarDecl ( .. ) 
849+                 | TokenTree :: MetaVarDecl   {  ..  } 
849850                | TokenTree :: MetaVarExpr ( ..)  => { 
850851                    first. add_one ( TtHandle :: TtRef ( tt) ) ; 
851852                    return  first; 
@@ -1084,7 +1085,7 @@ fn check_matcher_core<'tt>(
10841085        match  token { 
10851086            TokenTree :: Token ( ..) 
10861087            | TokenTree :: MetaVar ( ..) 
1087-             | TokenTree :: MetaVarDecl ( .. ) 
1088+             | TokenTree :: MetaVarDecl   {  ..  } 
10881089            | TokenTree :: MetaVarExpr ( ..)  => { 
10891090                if  token_can_be_followed_by_any ( token)  { 
10901091                    // don't need to track tokens that work with any, 
@@ -1152,7 +1153,7 @@ fn check_matcher_core<'tt>(
11521153        // Now `last` holds the complete set of NT tokens that could 
11531154        // end the sequence before SUFFIX. Check that every one works with `suffix`. 
11541155        for  tt in  & last. tokens  { 
1155-             if  let  & TokenTree :: MetaVarDecl ( span,  name,  Some ( kind) )  = tt. get ( )  { 
1156+             if  let  & TokenTree :: MetaVarDecl   {   span,  name,  kind  }  = tt. get ( )  { 
11561157                for  next_token in  & suffix_first. tokens  { 
11571158                    let  next_token = next_token. get ( ) ; 
11581159
@@ -1172,11 +1173,11 @@ fn check_matcher_core<'tt>(
11721173                        ) 
11731174                    { 
11741175                        // It is suggestion to use pat_param, for example: $x:pat -> $x:pat_param. 
1175-                         let  suggestion = quoted_tt_to_string ( & TokenTree :: MetaVarDecl ( 
1176+                         let  suggestion = quoted_tt_to_string ( & TokenTree :: MetaVarDecl   { 
11761177                            span, 
11771178                            name, 
1178-                             Some ( NonterminalKind :: Pat ( PatParam  {  inferred :  false  } ) ) , 
1179-                         ) ) ; 
1179+                             kind :   NonterminalKind :: Pat ( PatParam  {  inferred :  false  } ) , 
1180+                         } ) ; 
11801181                        sess. psess . buffer_lint ( 
11811182                            RUST_2021_INCOMPATIBLE_OR_PATTERNS , 
11821183                            span, 
@@ -1212,11 +1213,11 @@ fn check_matcher_core<'tt>(
12121213                                && sess. psess . edition . at_least_rust_2021 ( ) 
12131214                                && next_token. is_token ( & token:: Or ) 
12141215                            { 
1215-                                 let  suggestion = quoted_tt_to_string ( & TokenTree :: MetaVarDecl ( 
1216+                                 let  suggestion = quoted_tt_to_string ( & TokenTree :: MetaVarDecl   { 
12161217                                    span, 
12171218                                    name, 
1218-                                     Some ( NonterminalKind :: Pat ( PatParam  {  inferred :  false  } ) ) , 
1219-                                 ) ) ; 
1219+                                     kind :   NonterminalKind :: Pat ( PatParam  {  inferred :  false  } ) , 
1220+                                 } ) ; 
12201221                                err. span_suggestion ( 
12211222                                    span, 
12221223                                    "try a `pat_param` fragment specifier instead" , 
@@ -1254,7 +1255,7 @@ fn check_matcher_core<'tt>(
12541255} 
12551256
12561257fn  token_can_be_followed_by_any ( tok :  & mbe:: TokenTree )  -> bool  { 
1257-     if  let  mbe:: TokenTree :: MetaVarDecl ( _ ,  _ ,   Some ( kind) )  = * tok { 
1258+     if  let  mbe:: TokenTree :: MetaVarDecl   {   kind,  ..  }  = * tok { 
12581259        frag_can_be_followed_by_any ( kind) 
12591260    }  else  { 
12601261        // (Non NT's can always be followed by anything in matchers.) 
@@ -1367,7 +1368,7 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow {
13671368                        } 
13681369                        _ => IsInFollow :: No ( TOKENS ) , 
13691370                    } , 
1370-                     TokenTree :: MetaVarDecl ( _ ,  _ ,   Some ( NonterminalKind :: Block ) )  => IsInFollow :: Yes , 
1371+                     TokenTree :: MetaVarDecl   {   kind :   NonterminalKind :: Block ,  ..  }  => IsInFollow :: Yes , 
13711372                    _ => IsInFollow :: No ( TOKENS ) , 
13721373                } 
13731374            } 
@@ -1400,11 +1401,10 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow {
14001401                            } 
14011402                        } 
14021403                    } , 
1403-                     TokenTree :: MetaVarDecl ( 
1404-                         _, 
1405-                         _, 
1406-                         Some ( NonterminalKind :: Ident  | NonterminalKind :: Ty  | NonterminalKind :: Path ) , 
1407-                     )  => IsInFollow :: Yes , 
1404+                     TokenTree :: MetaVarDecl  { 
1405+                         kind :  NonterminalKind :: Ident  | NonterminalKind :: Ty  | NonterminalKind :: Path , 
1406+                         ..
1407+                     }  => IsInFollow :: Yes , 
14081408                    _ => IsInFollow :: No ( TOKENS ) , 
14091409                } 
14101410            } 
@@ -1416,8 +1416,7 @@ fn quoted_tt_to_string(tt: &mbe::TokenTree) -> String {
14161416    match  tt { 
14171417        mbe:: TokenTree :: Token ( token)  => pprust:: token_to_string ( token) . into ( ) , 
14181418        mbe:: TokenTree :: MetaVar ( _,  name)  => format ! ( "${name}" ) , 
1419-         mbe:: TokenTree :: MetaVarDecl ( _,  name,  Some ( kind) )  => format ! ( "${name}:{kind}" ) , 
1420-         mbe:: TokenTree :: MetaVarDecl ( _,  name,  None )  => format ! ( "${name}:" ) , 
1419+         mbe:: TokenTree :: MetaVarDecl  {  name,  kind,  .. }  => format ! ( "${name}:{kind}" ) , 
14211420        _ => panic ! ( 
14221421            "{}" , 
14231422            "unexpected mbe::TokenTree::{Sequence or Delimited} \  
0 commit comments