1
Fork 0

Only modify eof_items if token == Eof.

Because that's the condition under which `eof_items` is used.
This commit is contained in:
Nicholas Nethercote 2022-03-18 14:11:01 +11:00
parent 8bd1bcad58
commit 83044714a1

View file

@ -516,7 +516,8 @@ fn parse_tt_inner<'root, 'tt>(
bb_items: &mut SmallVec<[MatcherPosHandle<'root, 'tt>; 1]>, bb_items: &mut SmallVec<[MatcherPosHandle<'root, 'tt>; 1]>,
token: &Token, token: &Token,
) -> Option<NamedParseResult> { ) -> 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; let mut eof_items = EofItems::None;
// Pop items from `cur_items` until it is empty. // Pop items from `cur_items` until it is empty.
@ -592,11 +593,13 @@ fn parse_tt_inner<'root, 'tt>(
// If we are not in a repetition, then being at the end of a matcher means that we // 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. // have reached the potential end of the input.
debug_assert_eq!(idx, len); debug_assert_eq!(idx, len);
if *token == token::Eof {
eof_items = match eof_items { eof_items = match eof_items {
EofItems::None => EofItems::One(item), EofItems::None => EofItems::One(item),
EofItems::One(_) | EofItems::Multiple => EofItems::Multiple, EofItems::One(_) | EofItems::Multiple => EofItems::Multiple,
} }
} }
}
} else { } else {
// We are in the middle of a matcher. Look at what token in the matcher we are trying // We are in the middle of a matcher. Look at what token in the matcher we are trying
// to match the current token (`token`) against. Depending on that, we may generate new // to match the current token (`token`) against. Depending on that, we may generate new