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/expander/matcher.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'crates/mbe/src/expander') diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs index 3c53960ce..1682b21b0 100644 --- a/crates/mbe/src/expander/matcher.rs +++ b/crates/mbe/src/expander/matcher.rs @@ -710,7 +710,6 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult input .expect_ident() - .and_then(|ident| if ident.text == "_" { Err(()) } else { Ok(ident) }) .map(|ident| Some(tt::Leaf::from(ident.clone()).into())) .map_err(|()| err!("expected ident")), "tt" => input.expect_tt().map(Some).map_err(|()| err!()), @@ -763,7 +762,7 @@ impl<'a> TtIter<'a> { fn expect_separator(&mut self, separator: &Separator, idx: usize) -> bool { let mut fork = self.clone(); let ok = match separator { - Separator::Ident(lhs) if idx == 0 => match fork.expect_ident() { + Separator::Ident(lhs) if idx == 0 => match fork.expect_ident_or_underscore() { Ok(rhs) => rhs.text == lhs.text, _ => false, }, @@ -853,7 +852,7 @@ impl<'a> TtIter<'a> { if punct.char != '\'' { return Err(()); } - let ident = self.expect_ident()?; + let ident = self.expect_ident_or_underscore()?; Ok(tt::Subtree { delimiter: None, -- cgit v1.2.3