Skip to content

Commit 5bbbee5

Browse files
committed
Add two useful assertions.
1 parent 285fa7e commit 5bbbee5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

compiler/rustc_expand/src/mbe/macro_parser.rs

+2
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ fn parse_tt_inner<'root, 'tt>(
524524
// then we could be at the end of a sequence or at the beginning of the next
525525
// repetition.
526526
if let Some(repetition) = &item.repetition {
527+
debug_assert!(idx <= len + 1);
527528
debug_assert!(matches!(item.top_elts, Tt(TokenTree::Sequence(..))));
528529

529530
// At this point, regardless of whether there is a separator, we should add all
@@ -569,6 +570,7 @@ fn parse_tt_inner<'root, 'tt>(
569570
} else {
570571
// If we are not in a repetition, then being at the end of a matcher means that we
571572
// have reached the potential end of the input.
573+
debug_assert_eq!(idx, len);
572574
eof_items = match eof_items {
573575
EofItems::None => EofItems::One(item),
574576
EofItems::One(_) | EofItems::Multiple => EofItems::Multiple,

0 commit comments

Comments
 (0)