@@ -689,9 +689,14 @@ pub(super) fn parse_tt(parser: &mut Cow<'_, Parser<'_>>, ms: &[TokenTree]) -> Na
689689 // unnecessary implicit clone later in Rc::make_mut.
690690 drop ( eof_items) ;
691691
692+ // If there are no possible next positions AND we aren't waiting for the black-box parser,
693+ // then there is a syntax error.
694+ if bb_items. is_empty ( ) && next_items. is_empty ( ) {
695+ return Failure ( parser. token . clone ( ) , "no rules expected this token in macro call" ) ;
696+ }
692697 // Another possibility is that we need to call out to parse some rust nonterminal
693698 // (black-box) parser. However, if there is not EXACTLY ONE of these, something is wrong.
694- if ( !bb_items. is_empty ( ) && !next_items. is_empty ( ) ) || bb_items. len ( ) > 1 {
699+ else if ( !bb_items. is_empty ( ) && !next_items. is_empty ( ) ) || bb_items. len ( ) > 1 {
695700 let nts = bb_items
696701 . iter ( )
697702 . map ( |item| match item. top_elts . get_tt ( item. idx ) {
@@ -713,11 +718,6 @@ pub(super) fn parse_tt(parser: &mut Cow<'_, Parser<'_>>, ms: &[TokenTree]) -> Na
713718 ) ,
714719 ) ;
715720 }
716- // If there are no possible next positions AND we aren't waiting for the black-box parser,
717- // then there is a syntax error.
718- else if bb_items. is_empty ( ) && next_items. is_empty ( ) {
719- return Failure ( parser. token . clone ( ) , "no rules expected this token in macro call" ) ;
720- }
721721 // Dump all possible `next_items` into `cur_items` for the next iteration.
722722 else if !next_items. is_empty ( ) {
723723 // Now process the next token
0 commit comments