@@ -76,10 +76,10 @@ use TokenTreeOrTokenTreeSlice::*;
7676
7777use crate :: mbe:: { self , TokenTree } ;
7878
79- use rustc_ast:: token:: { self , DocComment , Nonterminal , NonterminalKind , Token } ;
79+ use rustc_ast:: token:: { self , DocComment , Nonterminal , Token } ;
8080use rustc_parse:: parser:: Parser ;
8181use rustc_session:: parse:: ParseSess ;
82- use rustc_span:: symbol:: { kw , MacroRulesNormalizedIdent } ;
82+ use rustc_span:: symbol:: MacroRulesNormalizedIdent ;
8383
8484use smallvec:: { smallvec, SmallVec } ;
8585
@@ -378,7 +378,7 @@ fn nameize<I: Iterator<Item = NamedMatch>>(
378378 n_rec ( sess, next_m, res. by_ref ( ) , ret_val) ?;
379379 }
380380 }
381- TokenTree :: MetaVarDecl ( span, _, id ) if id . name == kw :: Invalid => {
381+ TokenTree :: MetaVarDecl ( span, _, None ) => {
382382 if sess. missing_fragment_specifiers . borrow_mut ( ) . remove ( & span) . is_some ( ) {
383383 return Err ( ( span, "missing fragment specifier" . to_string ( ) ) ) ;
384384 }
@@ -561,18 +561,17 @@ fn inner_parse_loop<'root, 'tt>(
561561 }
562562
563563 // We need to match a metavar (but the identifier is invalid)... this is an error
564- TokenTree :: MetaVarDecl ( span, _, id ) if id . name == kw :: Invalid => {
564+ TokenTree :: MetaVarDecl ( span, _, None ) => {
565565 if sess. missing_fragment_specifiers . borrow_mut ( ) . remove ( & span) . is_some ( ) {
566566 return Error ( span, "missing fragment specifier" . to_string ( ) ) ;
567567 }
568568 }
569569
570570 // We need to match a metavar with a valid ident... call out to the black-box
571571 // parser by adding an item to `bb_items`.
572- TokenTree :: MetaVarDecl ( _, _, id ) => {
572+ TokenTree :: MetaVarDecl ( _, _, Some ( kind ) ) => {
573573 // Built-in nonterminals never start with these tokens,
574574 // so we can eliminate them from consideration.
575- let kind = NonterminalKind :: from_symbol ( id. name ) . unwrap ( ) ;
576575 if Parser :: nonterminal_may_begin_with ( kind, token) {
577576 bb_items. push ( item) ;
578577 }
@@ -703,7 +702,7 @@ pub(super) fn parse_tt(parser: &mut Cow<'_, Parser<'_>>, ms: &[TokenTree]) -> Na
703702 let nts = bb_items
704703 . iter ( )
705704 . map ( |item| match item. top_elts . get_tt ( item. idx ) {
706- TokenTree :: MetaVarDecl ( _, bind, name ) => format ! ( "{} ('{}')" , name , bind) ,
705+ TokenTree :: MetaVarDecl ( _, bind, Some ( kind ) ) => format ! ( "{} ('{}')" , kind , bind) ,
707706 _ => panic ! ( ) ,
708707 } )
709708 . collect :: < Vec < String > > ( )
@@ -733,17 +732,13 @@ pub(super) fn parse_tt(parser: &mut Cow<'_, Parser<'_>>, ms: &[TokenTree]) -> Na
733732 assert_eq ! ( bb_items. len( ) , 1 ) ;
734733
735734 let mut item = bb_items. pop ( ) . unwrap ( ) ;
736- if let TokenTree :: MetaVarDecl ( span, _, ident ) = item. top_elts . get_tt ( item. idx ) {
735+ if let TokenTree :: MetaVarDecl ( span, _, Some ( kind ) ) = item. top_elts . get_tt ( item. idx ) {
737736 let match_cur = item. match_cur ;
738- let kind = NonterminalKind :: from_symbol ( ident. name ) . unwrap ( ) ;
739737 let nt = match parser. to_mut ( ) . parse_nonterminal ( kind) {
740738 Err ( mut err) => {
741739 err. span_label (
742740 span,
743- format ! (
744- "while parsing argument for this `{}` macro fragment" ,
745- ident. name
746- ) ,
741+ format ! ( "while parsing argument for this `{}` macro fragment" , kind) ,
747742 )
748743 . emit ( ) ;
749744 return ErrorReported ;
0 commit comments