From 0a7f28620a7002f47890c2030862052bcbf25cdb Mon Sep 17 00:00:00 2001 From: Kevin Mehall Date: Sat, 20 Mar 2021 17:43:51 -0600 Subject: Fix and test edge cases of `_` as ident --- crates/mbe/src/tt_iter.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crates/mbe/src/tt_iter.rs') diff --git a/crates/mbe/src/tt_iter.rs b/crates/mbe/src/tt_iter.rs index a362d31fc..319a40f2a 100644 --- a/crates/mbe/src/tt_iter.rs +++ b/crates/mbe/src/tt_iter.rs @@ -49,6 +49,13 @@ impl<'a> TtIter<'a> { } pub(crate) fn expect_ident(&mut self) -> Result<&'a tt::Ident, ()> { + match self.expect_leaf()? { + tt::Leaf::Ident(it) if it.text != "_" => Ok(it), + _ => Err(()), + } + } + + pub(crate) fn expect_ident_or_underscore(&mut self) -> Result<&'a tt::Ident, ()> { match self.expect_leaf()? { tt::Leaf::Ident(it) => Ok(it), _ => Err(()), -- cgit v1.2.3