@@ -76,10 +76,10 @@ use TokenTreeOrTokenTreeSlice::*;
76
76
77
77
use crate :: mbe:: { self , TokenTree } ;
78
78
79
- use rustc_ast:: token:: { self , DocComment , Nonterminal , NonterminalKind , Token } ;
79
+ use rustc_ast:: token:: { self , DocComment , Nonterminal , Token } ;
80
80
use rustc_parse:: parser:: Parser ;
81
81
use rustc_session:: parse:: ParseSess ;
82
- use rustc_span:: symbol:: { kw , MacroRulesNormalizedIdent } ;
82
+ use rustc_span:: symbol:: MacroRulesNormalizedIdent ;
83
83
84
84
use smallvec:: { smallvec, SmallVec } ;
85
85
@@ -378,7 +378,7 @@ fn nameize<I: Iterator<Item = NamedMatch>>(
378
378
n_rec ( sess, next_m, res. by_ref ( ) , ret_val) ?;
379
379
}
380
380
}
381
- TokenTree :: MetaVarDecl ( span, _, id ) if id . name == kw :: Invalid => {
381
+ TokenTree :: MetaVarDecl ( span, _, None ) => {
382
382
if sess. missing_fragment_specifiers . borrow_mut ( ) . remove ( & span) . is_some ( ) {
383
383
return Err ( ( span, "missing fragment specifier" . to_string ( ) ) ) ;
384
384
}
@@ -561,18 +561,17 @@ fn inner_parse_loop<'root, 'tt>(
561
561
}
562
562
563
563
// 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 ) => {
565
565
if sess. missing_fragment_specifiers . borrow_mut ( ) . remove ( & span) . is_some ( ) {
566
566
return Error ( span, "missing fragment specifier" . to_string ( ) ) ;
567
567
}
568
568
}
569
569
570
570
// We need to match a metavar with a valid ident... call out to the black-box
571
571
// parser by adding an item to `bb_items`.
572
- TokenTree :: MetaVarDecl ( _, _, id ) => {
572
+ TokenTree :: MetaVarDecl ( _, _, Some ( kind ) ) => {
573
573
// Built-in nonterminals never start with these tokens,
574
574
// so we can eliminate them from consideration.
575
- let kind = NonterminalKind :: from_symbol ( id. name ) . unwrap ( ) ;
576
575
if Parser :: nonterminal_may_begin_with ( kind, token) {
577
576
bb_items. push ( item) ;
578
577
}
@@ -703,7 +702,7 @@ pub(super) fn parse_tt(parser: &mut Cow<'_, Parser<'_>>, ms: &[TokenTree]) -> Na
703
702
let nts = bb_items
704
703
. iter ( )
705
704
. 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) ,
707
706
_ => panic ! ( ) ,
708
707
} )
709
708
. collect :: < Vec < String > > ( )
@@ -733,17 +732,13 @@ pub(super) fn parse_tt(parser: &mut Cow<'_, Parser<'_>>, ms: &[TokenTree]) -> Na
733
732
assert_eq ! ( bb_items. len( ) , 1 ) ;
734
733
735
734
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 ) {
737
736
let match_cur = item. match_cur ;
738
- let kind = NonterminalKind :: from_symbol ( ident. name ) . unwrap ( ) ;
739
737
let nt = match parser. to_mut ( ) . parse_nonterminal ( kind) {
740
738
Err ( mut err) => {
741
739
err. span_label (
742
740
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) ,
747
742
)
748
743
. emit ( ) ;
749
744
return ErrorReported ;
0 commit comments