diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-03-18 14:11:01 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-03-18 14:11:01 +1100 |
| commit | 83044714a107dc80d0a85f300a4f7223c1a447bf (patch) | |
| tree | 519326cf1f2cc0e4947cda74ff4bad5ca83cfdd5 | |
| parent | 8bd1bcad5858eb79bd60f320c9251dd84aa3b017 (diff) | |
| download | rust-83044714a107dc80d0a85f300a4f7223c1a447bf.tar.gz rust-83044714a107dc80d0a85f300a4f7223c1a447bf.zip | |
Only modify `eof_items` if `token == Eof`.
Because that's the condition under which `eof_items` is used.
| -rw-r--r-- | compiler/rustc_expand/src/mbe/macro_parser.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_expand/src/mbe/macro_parser.rs b/compiler/rustc_expand/src/mbe/macro_parser.rs index 247327e94ba..0f8f12640cf 100644 --- a/compiler/rustc_expand/src/mbe/macro_parser.rs +++ b/compiler/rustc_expand/src/mbe/macro_parser.rs @@ -516,7 +516,8 @@ fn parse_tt_inner<'root, 'tt>( bb_items: &mut SmallVec<[MatcherPosHandle<'root, 'tt>; 1]>, token: &Token, ) -> Option<NamedParseResult> { - // Matcher positions that would be valid if the macro invocation was over now + // Matcher positions that would be valid if the macro invocation was over now. Only modified if + // `token == Eof`. let mut eof_items = EofItems::None; // Pop items from `cur_items` until it is empty. @@ -592,9 +593,11 @@ fn parse_tt_inner<'root, 'tt>( // If we are not in a repetition, then being at the end of a matcher means that we // have reached the potential end of the input. debug_assert_eq!(idx, len); - eof_items = match eof_items { - EofItems::None => EofItems::One(item), - EofItems::One(_) | EofItems::Multiple => EofItems::Multiple, + if *token == token::Eof { + eof_items = match eof_items { + EofItems::None => EofItems::One(item), + EofItems::One(_) | EofItems::Multiple => EofItems::Multiple, + } } } } else { |
