Fix and test edge cases of _ as ident

This commit is contained in:
Kevin Mehall 2021-03-20 17:43:51 -06:00
parent 0a0e22235b
commit 0a7f28620a
3 changed files with 13 additions and 3 deletions

View file

@ -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(()),