diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-03-25 15:32:34 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-03-29 08:00:26 +1100 |
| commit | df6ead557d6c1f2ec87793d95b8a8bc9453e0f66 (patch) | |
| tree | d6967064ae38d2d25026e35fd97aa402a6f4b406 | |
| parent | 600ec284838c52d1f6657c2cf0097b58970b133b (diff) | |
| download | rust-df6ead557d6c1f2ec87793d95b8a8bc9453e0f66.tar.gz rust-df6ead557d6c1f2ec87793d95b8a8bc9453e0f66.zip | |
Add a useful assertion.
| -rw-r--r-- | compiler/rustc_expand/src/mbe/macro_parser.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_expand/src/mbe/macro_parser.rs b/compiler/rustc_expand/src/mbe/macro_parser.rs index 5a6a2b2c57b..69da3f232a0 100644 --- a/compiler/rustc_expand/src/mbe/macro_parser.rs +++ b/compiler/rustc_expand/src/mbe/macro_parser.rs @@ -588,8 +588,13 @@ impl<'tt> TtParser<'tt> { if *token == token::Eof { Some(match eof_items { EofItems::One(mut eof_item) => { - let matches = - eof_item.matches.iter_mut().map(|dv| Lrc::make_mut(dv).pop().unwrap()); + let matches = eof_item.matches.iter_mut().map(|dv| { + // Top-level metavars only ever get one match. (Sub-matchers can get + // multiple matches, which get aggregated into a `MatcherSeq` before being + // put into the top-level.) + debug_assert_eq!(dv.len(), 1); + Lrc::make_mut(dv).pop().unwrap() + }); nameize(sess, ms, matches) } EofItems::Multiple => { |
