Skip to content

Commit df6ead5

Browse files
committed
Add a useful assertion.
1 parent 600ec28 commit df6ead5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compiler/rustc_expand/src/mbe/macro_parser.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,13 @@ impl<'tt> TtParser<'tt> {
588588
if *token == token::Eof {
589589
Some(match eof_items {
590590
EofItems::One(mut eof_item) => {
591-
let matches =
592-
eof_item.matches.iter_mut().map(|dv| Lrc::make_mut(dv).pop().unwrap());
591+
let matches = eof_item.matches.iter_mut().map(|dv| {
592+
// Top-level metavars only ever get one match. (Sub-matchers can get
593+
// multiple matches, which get aggregated into a `MatcherSeq` before being
594+
// put into the top-level.)
595+
debug_assert_eq!(dv.len(), 1);
596+
Lrc::make_mut(dv).pop().unwrap()
597+
});
593598
nameize(sess, ms, matches)
594599
}
595600
EofItems::Multiple => {

0 commit comments

Comments
 (0)