@@ -689,9 +689,14 @@ pub(super) fn parse_tt(parser: &mut Cow<'_, Parser<'_>>, ms: &[TokenTree]) -> Na
689
689
// unnecessary implicit clone later in Rc::make_mut.
690
690
drop ( eof_items) ;
691
691
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
+ }
692
697
// Another possibility is that we need to call out to parse some rust nonterminal
693
698
// (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 {
695
700
let nts = bb_items
696
701
. iter ( )
697
702
. 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
713
718
) ,
714
719
) ;
715
720
}
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
- }
721
721
// Dump all possible `next_items` into `cur_items` for the next iteration.
722
722
else if !next_items. is_empty ( ) {
723
723
// Now process the next token
0 commit comments