Skip to content

Commit 8304471

Browse files
committed
Only modify eof_items if token == Eof.
Because that's the condition under which `eof_items` is used.
1 parent 8bd1bca commit 8304471

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

compiler/rustc_expand/src/mbe/macro_parser.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,8 @@ fn parse_tt_inner<'root, 'tt>(
516516
bb_items: &mut SmallVec<[MatcherPosHandle<'root, 'tt>; 1]>,
517517
token: &Token,
518518
) -> Option<NamedParseResult> {
519-
// Matcher positions that would be valid if the macro invocation was over now
519+
// Matcher positions that would be valid if the macro invocation was over now. Only modified if
520+
// `token == Eof`.
520521
let mut eof_items = EofItems::None;
521522

522523
// Pop items from `cur_items` until it is empty.
@@ -592,9 +593,11 @@ fn parse_tt_inner<'root, 'tt>(
592593
// If we are not in a repetition, then being at the end of a matcher means that we
593594
// have reached the potential end of the input.
594595
debug_assert_eq!(idx, len);
595-
eof_items = match eof_items {
596-
EofItems::None => EofItems::One(item),
597-
EofItems::One(_) | EofItems::Multiple => EofItems::Multiple,
596+
if *token == token::Eof {
597+
eof_items = match eof_items {
598+
EofItems::None => EofItems::One(item),
599+
EofItems::One(_) | EofItems::Multiple => EofItems::Multiple,
600+
}
598601
}
599602
}
600603
} else {

0 commit comments

Comments
 (0)