aboutsummaryrefslogtreecommitdiff
path: root/crates/mbe/src/tt_iter.rs
diff options
context:
space:
mode:
authorKevin Mehall <[email protected]>2021-03-20 23:43:51 +0000
committerKevin Mehall <[email protected]>2021-03-20 23:54:57 +0000
commit0a7f28620a7002f47890c2030862052bcbf25cdb (patch)
treede1a04ded1589c0a3fa504cba606bfc8d89b3aa2 /crates/mbe/src/tt_iter.rs
parent0a0e22235b7ad222be1aaa7765b580f4096c9aeb (diff)
Fix and test edge cases of `_` as ident
Diffstat (limited to 'crates/mbe/src/tt_iter.rs')
-rw-r--r--crates/mbe/src/tt_iter.rs7
1 files changed, 7 insertions, 0 deletions
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
@@ -50,6 +50,13 @@ impl<'a> TtIter<'a> {
50 50
51 pub(crate) fn expect_ident(&mut self) -> Result<&'a tt::Ident, ()> { 51 pub(crate) fn expect_ident(&mut self) -> Result<&'a tt::Ident, ()> {
52 match self.expect_leaf()? { 52 match self.expect_leaf()? {
53 tt::Leaf::Ident(it) if it.text != "_" => Ok(it),
54 _ => Err(()),
55 }
56 }
57
58 pub(crate) fn expect_ident_or_underscore(&mut self) -> Result<&'a tt::Ident, ()> {
59 match self.expect_leaf()? {
53 tt::Leaf::Ident(it) => Ok(it), 60 tt::Leaf::Ident(it) => Ok(it),
54 _ => Err(()), 61 _ => Err(()),
55 } 62 }